Skip to content

class conversion is not possible #1568

@HyeockJinKim

Description

@HyeockJinKim

Feature

Converting class in Python to change to another class is not currently supported in Rustpython.

Actual Result

>>>>> class A:
.....  pass
..... 
>>>>> class B:
.....  pass
..... 
>>>>> a = A()
>>>>> a.__class__ = B
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't change class of type '<class 'A'>'

Expected result

>>> class A:
...  pass
... 
>>> class B:
...  pass
... 
>>> a = A()
>>> a.__class__ = B
>>> a.__class__
<class '__main__.B'>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatA discrepancy between RustPython and CPython

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions