gh-140348: Fix using | on unusual objects plus Unions#140383
gh-140348: Fix using | on unusual objects plus Unions#140383JelleZijlstra merged 2 commits intopython:mainfrom
Conversation
Fidget-Spinner
left a comment
There was a problem hiding this comment.
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. |
|
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
GH-140948 is a backport of this pull request to the 3.14 branch. |
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.