[Python-Dev] in a pickle: method lookup irregularities

Eric Snow ericsnowcurrently at gmail.com
Sun Feb 17 04:36:16 CET 2013


(See http://bugs.python.org/issue16251)

The pickle module looks up special methods on instances rather than
using the behavior described in the language reference (or even just
looking them up on the class).  This means that custom
__getattribute__() and __getattr__() implementations may get triggered
(e.g. if there is no __reduce__() implemented).

Bringing pickle in sync with the language reference would not involve
a big change, but it would impact anyone that relies on the current
behavior.  Most notably, proxy types could exist which leverage the
current semantics.

I look at this as trading one "bug" for another in a .  So I want to
get some general feedback on the situation and see what others
consider to be the trade-offs of fixing or not fixing this bug.  I'm
particularly interested in existing cases where code uses the current
behavior.  With that in hand we could assess what alternatives exist
in those cases or how we could better document workarounds for the
current behavior.

-eric


More information about the Python-Dev mailing list