This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients serhiy.storchaka
Date 2021-06-22.06:32:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624343546.88.0.657403133793.issue44483@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-06-22 06:32:26serhiy.storchakasetrecipients: + serhiy.storchaka
2021-06-22 06:32:26serhiy.storchakasetmessageid: <1624343546.88.0.657403133793.issue44483@roundup.psfhosted.org>
2021-06-22 06:32:26serhiy.storchakalinkissue44483 messages
2021-06-22 06:32:26serhiy.storchakacreate