[docs] [issue16242] Pickle and __getattr__
report at bugs.python.org
Mon Oct 15 20:11:13 CEST 2012
New submission from Joseph Fall:
This report is to re-raise an old issue from 2009:
Although that issue is marked as "fixed", I disagree that it was ever "fixed", and spent an evil day tracking it down.
- take two 3rd party packages: django and django-crispy-forms
- django, deep in its inner-workings, uses Pickle
- django-cripsy-forms implements the _getattr__ method in one of it's classes
- when you put the two together such that django pickles a form, the python interpreter goes into a tailspin in very sinister and hard-to-track-down ways (different behaviour in 2.5, 2.6, 2.7, as noted in issue5370, which includes a simple test case)
The "resolution" for issue5370 was to add some documentation to Pickle. But I would argue this is insufficient - the implementer of django-crispy-forms would have no reason to ever look at the Pickle docs, and so is very likely to implement this bug (which s/he did).
Perhaps, if this issue cannot be resolved in code, as suggested by gagenellina back in 2009, at least some documentation could be added to __getattr__ (and others) warning that these methods could potentially be called before __init__ (similar to the documentation added to Pickle)? I'd be happy to draft a small bit of documentation for this, although if someone can think of a way to simply resolve this in Pickle so it does not cause the issue in the first place, that seems to me ideal.
A test case is included with issue5370
assignee: docs at python
components: Documentation, Library (Lib)
nosy: docs at python, powderflask
title: Pickle and __getattr__
versions: Python 2.6, Python 2.7
Python tracker <report at bugs.python.org>
More information about the docs