[pygobject] pygtkcompat: Work around IndexError on large flags



commit d47283936b4c0b5e8b6ede8886c4badbf6d6e694
Author: Martin Pitt <martinpitt gnome org>
Date:   Thu Nov 29 16:45:49 2012 +0100

    pygtkcompat: Work around IndexError on large flags
    
    On 32 bit systems pygtkcompat currently fails with
    
      File "pygtkcompat/pygtkcompat.py", line 74, in _install_enums
        name = flag.value_names[-1].replace(modname + '_', '')
    IndexError: cannot fit 'int' into an index-sized integer
    
    on 32 bit systems as some flags in Gdk are too large to fit into a 32 bit
    "long". Work around this crash until this gets fixed properly (marked as
    FIXME).

 pygtkcompat/pygtkcompat.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/pygtkcompat/pygtkcompat.py b/pygtkcompat/pygtkcompat.py
index 7b37599..18ebd7b 100644
--- a/pygtkcompat/pygtkcompat.py
+++ b/pygtkcompat/pygtkcompat.py
@@ -71,7 +71,12 @@ def _install_enums(module, dest=None, strip=''):
         try:
             if issubclass(obj, GObject.GFlags):
                 for value, flag in obj.__flags_values__.items():
-                    name = flag.value_names[-1].replace(modname + '_', '')
+                    try:
+                        name = flag.value_names[-1].replace(modname + '_', '')
+                    except IndexError:
+                        # FIXME: this happens for some large flags which do not
+                        # fit into a long on 32 bit systems
+                        continue
                     setattr(dest, name, flag)
         except TypeError:
             continue



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]