Message396307
The following example crashes:
class TypeVar:
@property
def __module__(self):
1/0
str | TypeVar()
Output:
Fatal Python error: _Py_CheckSlotResult: Slot | of type type succeeded with an exception set
Python runtime state: initialized
Traceback (most recent call last):
File "<stdin>", line 4, in __module__
ZeroDivisionError: division by zero
Aborted (core dumped)
The problem in Objects/unionobject.c is that is_typing_module() (and therefore is_typevar() and is_special_form()) can return not only 0 and 1, but -1 as a signal of error, but is_unionable() does not check results for error and interprets it as boolean true. |
|
| Date |
User |
Action |
Args |
| 2021-06-22 06:32:26 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka |
| 2021-06-22 06:32:26 | serhiy.storchaka | set | messageid: <1624343546.88.0.657403133793.issue44483@roundup.psfhosted.org> |
| 2021-06-22 06:32:26 | serhiy.storchaka | link | issue44483 messages |
| 2021-06-22 06:32:26 | serhiy.storchaka | create | |
|