Open
Description
Bug Report
Code generated by mypyc crashes at run-time when accessing a read/write property of an interpreted subclass.
To Reproduce
The mypyc code:
#entity.py
from mypy_extensions import mypyc_attr
@mypyc_attr(allow_interpreted_subclasses=True)
class EntityBase:
def __init__(self) -> None:
self._name = 'hello'
@property
def name(self) -> str:
return self._name
@name.setter
def name(self, name: str):
self._name = name
def print_name_property(entity: EntityBase):
print(f'Property {type(entity)}: {entity.name}')
The driver code:
from reproducer import print_name_property, EntityBase
class EntitySubclass(EntityBase):
def __init__(self):
super().__init__()
def main():
entity_subclass = EntitySubclass()
print_name_property(entity_subclass)
if __name__ == '__main__':
main()
Expected Behavior
The code should print 'hello' regardless if the attribute is accessed directly or via property.
Actual Behavior
Program crashes, when calling print_name_property(entity_subclass)
:
Traceback (most recent call last):
File "/home/python/mypyc/reproducer.py", line 17, in <module>
main()
File "/home/python/mypyc/reproducer.py", line 13, in main
print_name_property(entity_subclass)
File "entity.py", line 20, in print_name_property
print(f'Property {type(entity)}: {entity.name}')
AttributeError: 'EntitySubclass' object has no attribute '__mypyc_setter__name'
Process finished with exit code 1
Your Environment
- Mypy version used: 1.4.1
- Python version used: 3.11.0