[Python-bugs-list] [ python-Bugs-749831 ] pickle raises SystemError when __getstate__ refers to class

SourceForge.net noreply@sourceforge.net
Fri, 06 Jun 2003 12:05:50 -0700


Bugs item #749831, was opened at 2003-06-05 22:04
Message generated for change (Comment added) made by gerrit
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=749831&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Gerrit Holl (gerrit)
Assigned to: Nobody/Anonymous (nobody)
Summary: pickle raises SystemError when __getstate__ refers to class

Initial Comment:
I'm sorry that I'm so far unable to track this down
better, but my app is quite complex I think. But if I'm
right cPickle should never raise a SystemError:

$ ./brian.py
mcop warning: user defined signal handler found for
SIG_PIPE, overriding
Traceback (most recent call last):
  File "./brian.py", line 265, in ?
    main()
  File "./brian.py", line 235, in main
    game.mainloop()
  File "./brian.py", line 100, in mainloop
    self.save(self.savefile)
  File "./brian.py", line 216, in save
    self.level.save(fp)
  File "level.py", line 113, in save
    cPickle.dump(self, f, -1)
SystemError: NULL object passed to Py_BuildValue
$ python -c 'import sys;print sys.version'
2.3b1+ (#2, Jun  4 2003, 17:16:59)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)]

When I use (Py)pickle instead of cPickle, the traceback
becomes:

$ ./brian.py
mcop warning: user defined signal handler found for
SIG_PIPE, overriding
Traceback (most recent call last):
  File "./brian.py", line 266, in ?
    main()
  File "./brian.py", line 236, in main
    game.mainloop()
  File "./brian.py", line 100, in mainloop
    self.save(self.savefile)
  File "./brian.py", line 217, in save
    self.level.save(fp)
  File "/home/gerrit/cvs/brian/level.py", line 114, in save
    cPickle.dump(self, f, -1)
  File "/usr/local/lib/python2.3/pickle.py", line 1382,
in dump
    Pickler(file, protocol, bin).dump(obj)
  File "/usr/local/lib/python2.3/pickle.py", line 231,
in dump
    self.save(obj)
  File "/usr/local/lib/python2.3/pickle.py", line 338,
in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/local/lib/python2.3/pickle.py", line 433,
in save_reduce
    save(state)
  File "/usr/local/lib/python2.3/pickle.py", line 293,
in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/local/lib/python2.3/pickle.py", line 663,
in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/local/lib/python2.3/pickle.py", line 695,
in _batch_setitems
    save(v)
  File "/usr/local/lib/python2.3/pickle.py", line 313,
in save
    rv = reduce(self.proto)
SystemError: NULL object passed to Py_BuildValue

'self' is an object whose __dict__ has 4 items. The
'data' item is a set (Sets.set) with approx. 450 items.
Those are all instances of a class Sprite or one of its
subclasses. This is where it goes wrong.

The interesting part is that if a reference to
__class__ in __getstate__ of this Sprite is commented
out, (line 200 of
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pybrian/brian/basesprites.py?annotate=1.18)
this bug no longer occurs. The file then pickled is
attached (it is gzipped). Unfortunately, the
__getstate__ relies on some images available.

The full CVS tree of the app concerned is available via
SF:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pybrian/brian/
When 'brian' is called without basesprites.py#200
commented out, this error occurs for Python 2.3.

I am going to try to track this down further tomorrow
and beyond, because I think that with the line in
getstate I am very far already.

Gerrit.

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

>Comment By: Gerrit Holl (gerrit)
Date: 2003-06-06 19:05

Message:
Logged In: YES 
user_id=13298

OK; one step further.
The __class__ does not exist in the dictionairy so it should
raise a KeyError. The above is true for any non-existing key
in this dictionairy.

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

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