-
-
Notifications
You must be signed in to change notification settings - Fork 353
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
add __copy__ and __deep_copy__ to Cancelled #3105
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3105 +/- ##
=======================================
Coverage 99.58% 99.58%
=======================================
Files 121 121
Lines 18166 18191 +25
Branches 3275 3278 +3
=======================================
+ Hits 18091 18116 +25
Misses 52 52
Partials 23 23
|
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.
Looks good as far as I can tell
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.
This is a far better copy than most exception objects have, FYI. (I left a comment on the flake8-trio issue that motivated this.)
Thank you! I think we don't need to bother doing it either then, and I'll throw out the complicated logic. |
it appears |
okay I think my original reasoning for this is no longer valid - copying is too unreliable to use in a general library like trio-websocket that needs to handle arbitrary user exceptions, but we should probably make it possible to copy & pickle That's fairly straightforward by implementing |
See python-trio/flake8-async#298 for why I want to be able to copy
Cancelled
.I suppose there's a minor footgun added if people start copying
Cancelled
,NoPublicConstructor
was added for a reason, but I think the gain outweighs it. Though of course another option is to simply get rid ofNoPublicConstructor
I initially tried to write cleaner methods, where I was using
__dict__
and the like, but they do not appear to pick up the relevant dunders so I simply listed everything relevant from https://docs.python.org/3/library/exceptions.html#exception-context