-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Python 3.11.9 catches all exceptions raised in Generic.__setattr__("__orig_class__", type_parameter)
#117744
Comments
I'm using Windows, and found that Python 3.12.3 and current main branch (02f1385) doesn't raise the exception too. |
Also from motivation of that PR I don't see a reasonable way to revert that pr without breaking original issue it was intended for. So I'd discourage relying on modifying edit: I misremembered PEP 560. |
Thank you for your reply!
RIght, I appreciate that
Catching all |
Tweaking the set of exceptions caught is bound to cause more bugs in the future, if someone has a buggy My inclination is to close this as "won't fix", and decide that your use case is unsupported. |
Honestly, I think the only reasonable exception for people to raise in Note that although #115165 was only reported regarding class Foo[T]:
def __setattr__(self, attr):
raise RuntimeError("NO!")
Foo[int]() That feels like really surprising behaviour to me; I think it would be unacceptable to go back to that. I agree with @JelleZijlstra here; I think we have to close this as "won't fix". |
Alright, got it! Think I might have found a way to resolve this without relying on Thanks for you time and feedback! |
No problem -- thanks for the well-written bug report @nanne-aben! |
Bug report
Bug description:
In Python 3.11.9, the following code does not raise an
Exception
:In other versions of Python (e.g. 3.11.8 or 3.12.2) this raises an
Exception
, but in Python 3.11.9 it appears thisException
is caught.I use something similar to the above logic in typedspark to check whether the
DataSet
follows the schema specified inSchema
, and I raise anException
if it doesn't. As of Python 3.11.9, these exceptions are caught, hence breaking my logic.Thank you for looking into this!
CPython versions tested on:
3.9, 3.10, 3.11, 3.12
Operating systems tested on:
Linux, macOS, Windows
The text was updated successfully, but these errors were encountered: