Commits

Ronny Pfannschmidt committed 838545b

also relace _basestring with six

Comments (0)

Files changed (1)

 diff --git a/py/__init__.py b/py/__init__.py
 --- a/py/__init__.py
 +++ b/py/__init__.py
-@@ -80,20 +80,20 @@ sys.modules['py.error'] = _apipkg.AliasM
+@@ -80,30 +80,30 @@ sys.modules['py.error'] = _apipkg.AliasM
      # backports and additions of builtins
      'builtin' : {
          '__doc__'        : '._builtin:__doc__',
 +        '_reraise'       : 'six:reraise',
          '_tryimport'     : '._builtin:_tryimport',
 -        'exec_'          : '._builtin:exec_',
+-        '_basestring'    : '._builtin:_basestring',
 +        'exec_'          : 'six:exec_',
-         '_basestring'    : '._builtin:_basestring',
++        '_basestring'    : 'six:string_types',
          '_totext'        : '._builtin:_totext',
          '_isbytes'       : '._builtin:_isbytes',
-@@ -101,9 +101,9 @@ sys.modules['py.error'] = _apipkg.AliasM
+         '_istext'        : '._builtin:_istext',
          '_getimself'     : '._builtin:_getimself',
          '_getfuncdict'   : '._builtin:_getfuncdict',
          '_getcode'       : '._builtin:_getcode',
      BaseException = BaseException
  except NameError:
      BaseException = Exception
-@@ -107,8 +17,23 @@ except NameError:
+@@ -107,12 +17,26 @@ except NameError:
  
  _sysex = (KeyboardInterrupt, SystemExit, MemoryError, GeneratorExit)
  
      import builtins
  
      # some backward compatibility helpers
-@@ -120,20 +45,6 @@ if sys.version_info >= (3, 0):
+-    _basestring = str
+     def _totext(obj, encoding=None):
+         if isinstance(obj, bytes):
+             obj = obj.decode(encoding)
+@@ -120,20 +44,6 @@ if sys.version_info >= (3, 0):
              obj = str(obj)
          return obj
  
      def execfile(fn, globs=None, locs=None):
          if globs is None:
              back = sys._getframe(1)
-@@ -150,78 +61,14 @@ if sys.version_info >= (3, 0):
+@@ -150,78 +60,13 @@ if sys.version_info >= (3, 0):
          co = compile(source, fn, "exec", dont_inherit=True)
          exec_(co, globs, locs)
  
  else:
      import __builtin__ as builtins
      _totext = unicode
-     _basestring = basestring
+-    _basestring = basestring
      execfile = execfile
 -    callable = callable
 -    def _isbytes(x):
  
  def _tryimport(*names):
      """ return the first successfully imported module. """
-@@ -231,4 +78,4 @@ def _tryimport(*names):
+@@ -231,4 +76,4 @@ def _tryimport(*names):
              return __import__(name, None, None, '__doc__')
          except ImportError:
              excinfo = sys.exc_info()