New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:

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.

----------
assignee: serhiy.storchaka
components: Interpreter Core
messages: 396307
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Fatal error in type union
type: crash
versions: Python 3.10, Python 3.11

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44483>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to