-
-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
unpickling vs. __getattr__ #49620
Comments
The attached short file causes all of python 2.5, 2.6 and 3.0 to drop A simple workaround is to provide this: def __setstate__(self, data):
self.__dict__.update(data) but methinks that either 1) the interpreter shouldn't be falling into |
The __getattr__ method, as written, assumes that an attribute 'args' def __getattr__(self, name):
if 'attrs' in self.__dict__ and name in self.attrs:
return self.attrs[name]
raise AttributeError(name) The suggestion of using hasattr in pickle code doesn't work, because I could not reproduce it with 2.6, nor the trunk -- there is another |
The args attribute gets created by __init__ and nothing in the class Any feature access can be made more robust by checking for it in |
Perhaps this should be made more clear in the http://docs.python.org/library/pickle.html#the-pickle- Could you come with some enhancements? (Note that it already states that __init__ is not |
I don't believe in documenting bugs instead of fixing them. If this bug The __init__ case is different - there isn't a common use case (this one |
QAD patch for 2.6 pickle.py to fix this bug. Passes the 2.6 pickle unit |
Are you sure you uploaded the right patch? I've not tested it, but I __setstate__ is *very* unlikely to be found in the instance's dict, so If no test failed, this may indicate bad test coverage. |
True. But hat's why it was a QAD hack - all I did was make sure it didn't blow up on the It really needs to walk the class tree. So something like hasattr(inst.__class__, And yes, the pickle unit tests apparently don't test the __*state__ routines, but that's a |
I think that trying to emulate all "getattr" details in the middle of There should be a warning note about __getattr__ in the pickle |
This doc update should warn people about the need to implement The patch is against trunk; wording for 3.x should omit references to |
Updated docs in r71240. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: