-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Avoid error if origin has a buggy __eq__ #422
Conversation
This is a good solution. Something we could also do is to check that |
Not sure that applies here, since in the pydantic stacktrace we're still being invoked from |
Yes, I don't think it applies here, I'm just inclined at this point to err on the side of absolute caution when it comes to this hack :-) Have you been able to figure out exactly why the |
(To be clear I don't think we need to necessarily have a test for this one, since it's pretty obvious that this would fix it. But I'd still be curious to know exactly what the cause of this is, if we can figure it out. We don't need to figure it out before merging this.) |
Yeah, I don't understand the NameError either. I was able to reproduce the failure in a test:
Though it only reproduces on 3.8 for some reason. |
That test looks good enough to me; it's raising the
Yeah, and the same with the pydantic test failure, right? Maybe something about frames where it wouldn't lookup globals properly under tracing got fixed in Python 3.9. Who knows. |
Actually the NameError appears to be because the error happens while |
I guess I found a CPython bug too. |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
If we want to be maximally paranoid, we could also make this change: --- a/src/typing_extensions.py
+++ b/src/typing_extensions.py
@@ -2954,8 +2954,10 @@ if not _PEP_696_IMPLEMENTED:
def _has_generic_or_protocol_as_origin() -> bool:
try:
frame = sys._getframe(2)
- # not all platforms have sys._getframe()
- except AttributeError:
+ # - Catch AttributeError: not all Python implementations have sys._getframe()
+ # - Catch ValueError: maybe we're called from an unexpected module
+ # and the call stack isn't deep enough
+ except (AttributeError, ValueError): |
I guess I get to fix another critical bug. |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
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.
LGTM
#419