Title: Pickle and __getattr__
Type: behavior Stage:
Components: Documentation, Library (Lib) Versions: Python 3.4, Python 3.5, Python 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: alexandre.vassalotti, docs@python, pitrou, powderflask
Priority: normal Keywords:

Created on 2012-10-15 18:11 by powderflask, last changed 2019-04-26 19:37 by BreamoreBoy.

Messages (2)
msg172993 - (view) Author: Joseph Fall (powderflask) Date: 2012-10-15 18:11
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. 

Use Case:
- 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
msg223114 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-15 15:07
@Joseph please accept our apologies for the delay in getting back to you.
Date User Action Args
2019-04-26 19:37:31BreamoreBoysetnosy: - BreamoreBoy
2014-07-15 15:07:00BreamoreBoysetnosy: + alexandre.vassalotti, BreamoreBoy, pitrou

messages: + msg223114
versions: + Python 3.4, Python 3.5, - Python 2.6
2012-10-15 18:11:13powderflaskcreate