[Python-bugs-list] [ python-Bugs-502085 ] pickle problems (with Boost.Python)

noreply@sourceforge.net noreply@sourceforge.net
Thu, 10 Jan 2002 14:49:23 -0800


Bugs item #502085, was opened at 2002-01-10 14:49
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=502085&group_id=5470

Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Ralf W. Grosse-Kunstleve (rwgk)
Assigned to: Nobody/Anonymous (nobody)
Summary: pickle problems (with Boost.Python)

Initial Comment:
Boost.Python 
(http://www.boost.org/libs/python/doc/index.html) is a
popular package for integrating Python and C++.

Boost.Python pickle support is broken when using 
Python 2.2 final, but
works with Python 2.2c1.

I noticed this difference:

diff /usr/local_cci/Python-
2.2/lib/python2.2/pickle.py /usr/local_cci/Python-
2.2c1/lib/python2.2/pickle.py
26c26
< __version__ = "$Revision: 1.56 $"       # Code 
version
---
> __version__ = "$Revision: 1.55 $"       # Code 
version
166,169d165
<             if issubclass(t, TypeType):
<                 self.save_global(object)
<                 return

I inserted one line in pickle.py:

% diff /usr/local_cci/Python-
2.2/lib/python2.2/pickle.py .
165a166
>             print "t", t

Result:

t <extension class pickle1.world at 1400c9c08>
t 
<boost::python::meta_class<boost::python::detail::exten
sion_instance> object at 0x3ffffe41ae0>
Traceback (most recent call last):
  File "zi", line 9, in ?
    pstr = pickle.dumps(wd)
  File "pickle.py", line 974, in dumps
    Pickler(file, bin).dump(object)
  File "pickle.py", line 115, in dump
    self.save(object)
  File "pickle.py", line 216, in save
    self.save_reduce(callable, arg_tup, state)
  File "pickle.py", line 241, in save_reduce
    save(callable)
  File "pickle.py", line 167, in save
    if issubclass(t, TypeType):
TypeError: issubclass() arg 1 must be a class

The following patch restores backward-compatibility:

% diff /usr/local_cci/Python-
2.2/lib/python2.2/pickle.py .
166,168c166,173
<             if issubclass(t, TypeType):
<                 self.save_global(object)
<                 return
---
>             try:
>                 issc = issubclass(t, TypeType)
>             except TypeError:
>                 pass
>             else:
>                 if issc:
>                     self.save_global(object)
>                     return

Remark: I also noticed that 2.2 cPickle still works 
for us
(double-checked) even though the CVS logs indicate 
that it was
also modified between 2.2c1 and 2.2.

Thanks,
        Ralf


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=502085&group_id=5470