Repository navigation
Pickling is losing some fields on exceptions #103333
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Apr 7, 2023 Why don't values like name/obj appear in
__dict__for exceptions? I see that if that were the case,BaseException's default reduce should have worked out here.It looks very related to #73652
If you agree, let's move there :)I think its the same overall problem, but i'm not really fit to come up with the be-all-end-all solution to the problem for all exceptions and their fields. (Which is where that issues seems to point).
For now I'd like to just try to fix this for AttributeError (if that's ok)... i've raised #103352 if you could check it.
- added3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Apr 21, 2023 - addedtype-featureA feature request or enhancementA feature request or enhancementand removed3.11only security fixesonly security fixes
on May 12, 2023 Thanks for the contribution, merged! I'm considering this a feature and doing it for 3.12 only as it can be seen as an API enhancement otherwise so doing this mid-cycle in 3.11 unless it were a regression from past releases doesn't feel right.
@sobolevn is right that there is a larger all Exceptions issue that could be dealt with, but this is still a meaningful improvement in the interim.
Reacted by Charles Machalow- added a commit that references this issue
on May 13, 2023
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Bug report
Say we have an AttributeError with some fields on it (like name). When we pickle and unpickle it, we can see that .name (at least) is lost (and set to None). Optimally those fields should still be in-tact on the unpickled instance.
Your environment
Same thing seems to happen on 3.10.7 and 3.11.3 as well.
Linked PRs