[issue2572] 3.0 pickle docs -- what about old-style classes?

Alexandre Vassalotti report at bugs.python.org
Mon Apr 7 23:51:28 CEST 2008


Alexandre Vassalotti <alexandre at peadrop.com> added the comment:

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'

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2572>
__________________________________


More information about the Python-bugs-list mailing list