[pygobject/pygobject-2-28] [python3] Fix maketrans import



commit 667bec76ccbc85cc1d54a0e68977dbda241c028c
Author: Martin Pitt <martin pitt ubuntu com>
Date:   Wed Jul 13 08:42:22 2011 +0200

    [python3] Fix maketrans import
    
    Python3 moved the maketrans() function from the string module to a str method.
    This unbreaks gi/module.py for Python 3 again.

 gi/module.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gi/module.py b/gi/module.py
index 70df76c..d56bdaf 100644
--- a/gi/module.py
+++ b/gi/module.py
@@ -24,7 +24,11 @@ from __future__ import absolute_import
 
 import os
 import gobject
-import string
+try:
+    maketrans = ''.maketrans
+except AttributeError:
+    # fallback for Python 2
+    from string import maketrans
 
 import gi
 from .overrides import registry
@@ -124,7 +128,7 @@ class IntrospectionModule(object):
                 # Don't use upper() here to avoid locale specific
                 # identifier conversion (e. g. in Turkish 'i'.upper() == 'i')
                 # see https://bugzilla.gnome.org/show_bug.cgi?id=649165
-                ascii_upper_trans = string.maketrans(
+                ascii_upper_trans = maketrans(
                         'abcdefgjhijklmnopqrstuvwxyz', 
                         'ABCDEFGJHIJKLMNOPQRSTUVWXYZ')
                 for value_info in info.get_values():



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