Skip to content

__new__ should be a static method #1230

@Lynskylate

Description

@Lynskylate

In RustPython, __new__ is bound method but it should be a static method.

class A:
    def __new__(*args, **kwargs):
        print("Args Total: {}".format(len(args)+len(kwargs)))

class B(A):
    def __new__(cls, *args, **kwargs):
        return super().__new__(cls, *args, **kwargs)
"""
>>> B()
CPython output
Args Total: 1 
RustPython output
Args Total: 2
"""

super().new(cls, *args, **kwargs) will pass two same ype class(args[0] is same as cls).

object __new__ Python docuemtion

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatA discrepancy between RustPython and CPython

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions