classification
Title: 3.0 pickle docs -- what about old-style classes?
Type: Stage:
Components: Documentation Versions: Python 3.0
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: alexandre.vassalotti Nosy List: alexandre.vassalotti, asmodai, benjamin.peterson, georg.brandl, rhettinger
Priority: normal Keywords:

Created on 2008-04-07 19:18 by georg.brandl, last changed 2009-04-27 16:22 by georg.brandl. This issue is now closed.

Messages (7)
msg65098 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-04-07 19:18
Can 3.0 unpickle pickled old-style classes? Which pickling methods are
supported? Etc.
msg65126 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-04-07 21:51
Python 3.0 shouldn't have any problem unpickling old-style classes.
However, they will be unpickled as new-style classes. Therefore, there
might be a few corner-cases that might cause some problems. For example,
if an old-style class contains a __slots__:

Python 2.5.1 (r251:54863, Mar  7 2008, 04:10:12) 
>>> import pickle
>>> class A:
...   __slots__ = []
... 
>>> pickle.dumps(A())
'(i__main__\nA\np0\n(dp1\nb.'

Python 3.0a3+ (py3k:62050M, Mar 30 2008, 17:29:33) 
>>> class A:
...   __slots__ = []
... 
>>> pickle.loads(b'(i__main__\nA\np0\n(dp1\nb.')
Traceback (most recent call last):
  ...
TypeError: __class__ assignment: '_EmptyClass' deallocator differs from 'A'
msg67354 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-05-25 19:53
Alexandre, would you mind fixing up the docs?
msg86493 - (view) Author: Jeroen Ruigrok van der Werven (asmodai) * (Python committer) Date: 2009-04-25 12:40
We want to document that old-style classes get converted into new-style
classes and that in general this goes without problems, except for some
corner cases such as containing a __slots__ directive? Or did I miss
anything else?
msg86521 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-25 15:00
Sounds like this is the best that we without intimate pickle knowledge
can do :)
msg86604 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-04-26 20:47
Recommend that this be closed with no action taken.  It is an important
step for Py3.x that old style classes be left behind and that no mention
of them occur in the 3.x docs.  Let's not carry 2.x with us into the 3.x
world.  The whole point was to leave the old world behind.

Also, the issue is not new in the sense that any cross-version pickling
may exercise functions or classes that did not exist in other versions
or whose meaning changed over time.  This is the nature of cross-version
pickling.

If someone wants to make pickling notes on the Python wiki, that would
be fine.  The pickling docs are already somewhat lengthy and complex,
yet will never cover every issue someone could think up.
msg86674 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-27 16:22
Okay, as the original submitter I withdraw this request.
History
Date User Action Args
2009-04-27 16:22:13georg.brandlsetstatus: open -> closed
resolution: rejected
messages: + msg86674
2009-04-26 20:47:56rhettingersetnosy: + rhettinger
messages: + msg86604
2009-04-25 15:00:29georg.brandlsetmessages: + msg86521
2009-04-25 12:40:21asmodaisetnosy: + asmodai
messages: + msg86493
2008-05-25 19:54:00benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg67354
2008-04-07 21:51:27alexandre.vassalottisetmessages: + msg65126
2008-04-07 19:18:19georg.brandlcreate