homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: cPickle error with gtk GEnum classes
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: _doublep, loewis, pyscripter
Priority: normal Keywords:

Created on 2008年02月28日 13:46 by pyscripter, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Messages (6)
msg63091 - (view) Author: PyScripter (pyscripter) Date: 2008年02月28日 13:46
cPickle has problems loading instances of gtk gobject.GEnum classes. 
gobject.GEnum is a subclass of int. On the other hand pickle handles
those classes correctly. Since cPickle is meant to be a faster version
of pickle this needs to be consider a bug. 
To test run the following script:
import gtk
##import pickle
import cPickle as pickle
simple_types = (
 bool,
 int,
 long,
 float,
 complex,
 basestring,
 type(None),
)
d = vars(gtk)
for (i,j) in d.iteritems():
 if isinstance(j, simple_types):
 try:
 s = pickle.dumps(j, pickle.HIGHEST_PROTOCOL)
 obj = pickle.loads(s)
 except (ValueError, TypeError):
 print j, type(j)
If you replace cPickle with pickle then the script runs fine.
msg63106 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008年02月28日 21:29
Can you please investigate the details and report the cause of the problem?
msg63113 - (view) Author: Paul Pogonyshev (_doublep) Date: 2008年02月28日 23:19
Using slightly modified PyGObject (so that it gives more useful error
message in pyg_enum_new) and adding 'raise' in the end of attached
example, I got this:
<enum GTK_RC_TOKEN_LOWEST of type GtkRcTokenType> <class
'gtk._gtk.RcTokenType'>
Traceback (most recent call last):
 File "<stdin>", line 5, in <module>
ValueError: value out of range (294 not in 0..40)
Not sure what it means yet...
msg63114 - (view) Author: Paul Pogonyshev (_doublep) Date: 2008年02月28日 23:27
It doesn't seem 'pickle' itself works:
>>> import pickle
>>> import gtk
>>> s = pickle.dumps (gtk.RC_TOKEN_LOWEST, pickle.HIGHEST_PROTOCOL)
>>> pickle.loads (s)
__main__:1: Warning: cannot retrieve class for invalid (unclassed) type
`<invalid>'
** ERROR **: file pygenum.c: line 55 (pyg_enum_repr): assertion failed:
(G_IS_ENUM_CLASS(enum_class))
aborting...
Aborted
msg63125 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008年02月29日 06:08
This all look like a bug in pygtk to me, not like a bug in pickle/cPickle.
msg63148 - (view) Author: Paul Pogonyshev (_doublep) Date: 2008年02月29日 22:45
Please close this issue. It is a PyGObject bug, nothing to do with
Python: http://bugzilla.gnome.org/show_bug.cgi?id=519645 
History
Date User Action Args
2022年04月11日 14:56:31adminsetgithub: 46452
2008年02月29日 22:56:47loewissetstatus: open -> closed
resolution: not a bug
2008年02月29日 22:45:47_doublepsetmessages: + msg63148
2008年02月29日 06:08:03loewissetmessages: + msg63125
2008年02月28日 23:27:08_doublepsetmessages: + msg63114
2008年02月28日 23:19:49_doublepsetnosy: + _doublep
messages: + msg63113
2008年02月28日 21:29:56loewissetnosy: + loewis
messages: + msg63106
2008年02月28日 13:46:23pyscriptercreate

AltStyle によって変換されたページ (->オリジナル) /