-
-
Couldn't load subscription status.
- Fork 33.3k
gh-140348: Fix using | on unusual objects plus Unions #140383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I havent heavily been involved in unionobject.c or genericaliasobject.c in about 4 years. But from what I recall, LGTM.
|
CI is red, this PR breaks some tests. |
|
Oops, pushed a new version that does not impact other types. |
|
Is it okay that now we have two variants of |
|
They don't, and maybe they should, but the behavior is the same in 3.13 and 3.14, so it's not part of the current issue. This PR focuses only on fixing the regression in 3.14. |
This restores the 3.13 behavior where
Union[A, B] | ...was almost always allowed, rejecting only things thattyping._type_checkrejects.It also necessarily means that something like
int | str | "float"now works. And if a third-party type implements__ror__on union objects and does something other than create a union, it may no longer work.