-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
RFCRequest for commentsRequest for comments
Description
Summary
Setting object's class attribute to a type with different layout cause panic
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', vm/src/object/core.rs:813:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
which is an error in cpython
TypeError: __class__ assignment: 'TypeB' object layout differs from 'TypeA'
Detailed Explanation
class TypeA:
def __init__(self) -> None:
self.a = 1
class TypeB:
__slots__ = "b"
def __init__(self) -> None:
self.b = 2
obj = TypeA()
assert obj.a == 1
obj.__class__ = TypeB
print(obj.b)
Copilot
Metadata
Metadata
Assignees
Labels
RFCRequest for commentsRequest for comments