Ken Jin <kenjin4...@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 <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