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 kj
Recipients kj, serhiy.storchaka
Date 2021-06-22.11:11:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624360270.42.0.130260751731.issue44483@roundup.psfhosted.org>
In-reply-to
Content
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?
History
Date User Action Args
2021-06-22 11:11:10kjsetrecipients: + kj, serhiy.storchaka
2021-06-22 11:11:10kjsetmessageid: <1624360270.42.0.130260751731.issue44483@roundup.psfhosted.org>
2021-06-22 11:11:10kjlinkissue44483 messages
2021-06-22 11:11:10kjcreate