[Python-bugs-list] [ python-Bugs-582297 ] pickle error message unhelpful
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 16 Jul 2002 08:22:27 -0700
Bugs item #582297, was opened at 2002-07-16 11:22
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=582297&group_id=5470
Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Dave Aitel (wabe0x90)
Assigned to: Nobody/Anonymous (nobody)
Summary: pickle error message unhelpful
Initial Comment:
Version: Python 2.2 (#1, Feb 24 2002, 16:21:58)
I was trying to pickle a class which had an open
socket, the exception I got was:
File "/usr/lib/python2.2/pickle.py", line 969, in dump
Pickler(file, bin).dump(object)
File "/usr/lib/python2.2/pickle.py", line 115, in dump
self.save(object)
File "/usr/lib/python2.2/pickle.py", line 221, in save
f(self, object)
File "/usr/lib/python2.2/pickle.py", line 494, in
save_inst
save(stuff)
File "/usr/lib/python2.2/pickle.py", line 221, in save
f(self, object)
File "/usr/lib/python2.2/pickle.py", line 443, in
save_dict
save(value)
File "/usr/lib/python2.2/pickle.py", line 221, in save
f(self, object)
File "/usr/lib/python2.2/pickle.py", line 494, in
save_inst
save(stuff)
File "/usr/lib/python2.2/pickle.py", line 221, in save
f(self, object)
File "/usr/lib/python2.2/pickle.py", line 443, in
save_dict
save(value)
File "/usr/lib/python2.2/pickle.py", line 185, in save
tup = reduce()
File "/usr/lib/python2.2/copy_reg.py", line 57, in
_reduce
state = base(self)
TypeError: an integer is required
Only by adding this to copy_reg.py was I able to figure
out what was really going on:
def _reduce(self):
for base in self.__class__.__mro__:
if hasattr(base, '__flags__') and not
base.__flags__ & _HEAPTYPE:
break
else:
base = object # not really reachable
if base is object:
state = None
else:
################I added the next line
print "dave: type of self="+str(self)
state = base(self)
args = (self.__class__, base, state)
It would be REALLY nice if pickle returned some sort of
better error message so I didn't have to do that,
especially for beginers like myself. :>
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=582297&group_id=5470