Skip to content

cPickle error with gtk GEnum classes #46452

Closed

Description

@pyscripter
BPO 2199
Nosy @loewis

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-02-29.22:56:47.860>
created_at = <Date 2008-02-28.13:46:23.169>
labels = ['invalid', 'library']
title = 'cPickle error with gtk GEnum classes'
updated_at = <Date 2008-02-29.22:56:47.859>
user = 'https://bugs.python.org/pyscripter'

bugs.python.org fields:

activity = <Date 2008-02-29.22:56:47.859>
actor = 'loewis'
assignee = 'none'
closed = True
closed_date = <Date 2008-02-29.22:56:47.860>
closer = 'loewis'
components = ['Library (Lib)']
creation = <Date 2008-02-28.13:46:23.169>
creator = 'pyscripter'
dependencies = []
files = []
hgrepos = []
issue_num = 2199
keywords = []
message_count = 6.0
messages = ['63091', '63106', '63113', '63114', '63125', '63148']
nosy_count = 3.0
nosy_names = ['loewis', '_doublep', 'pyscripter']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue2199'
versions = ['Python 2.5']

Activity

  1. pyscripter commented on Feb 28, 2008

    pyscriptermannequin
    MannequinAuthor

    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.

  2. added
    stdlib
    on Feb 28, 2008
  3. loewis commented on Feb 28, 2008

    loewismannequin
    Mannequin

    Can you please investigate the details and report the cause of the problem?

  4. doublep commented on Feb 28, 2008

    doublepmannequin
    Mannequin

    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...

  5. doublep commented on Feb 28, 2008

    doublepmannequin
    Mannequin

    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

  6. loewis commented on Feb 29, 2008

    loewismannequin
    Mannequin

    This all look like a bug in pygtk to me, not like a bug in pickle/cPickle.

  7. doublep commented on Feb 29, 2008

    doublepmannequin
    Mannequin

    Please close this issue. It is a PyGObject bug, nothing to do with
    Python: http://bugzilla.gnome.org/show_bug.cgi?id=519645

  8. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions