[issue44483] Fatal error in type union
Ken Jin
report at bugs.python.org
Tue Jun 22 07:11:10 EDT 2021
Ken Jin <kenjin4096 at gmail.com> added the comment:
A possible simple fix is to change these lines https://github.com/python/cpython/blob/main/Objects/unionobject.c#L294-L301
to:
```
return (
is_typevar(obj) |
is_new_type(obj) |
is_special_form(obj) |
PyType_Check(obj) |
PyObject_TypeCheck(obj, &Py_GenericAliasType) |
(int)(type == &_Py_UnionType));
```
However, that may slow down union a little since we lose the short-circuiting that `||` provides over `|`, and all checks have to be evaluated.
Checking each result individually and mimicking the short circuiting behavior works too, so I did that. What do you think Serhiy?
----------
stage: patch review ->
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44483>
_______________________________________
More information about the Python-bugs-list
mailing list