Пример #1
0
 def descr_decode(self, space, w_encoding=None, w_errors=None):
     from pypy.objspace.std.unicodeobject import (
         _get_encoding_and_errors, decode_object, unicode_from_string)
     encoding, errors = _get_encoding_and_errors(space, w_encoding,
                                                 w_errors)
     if encoding is None and errors is None:
         return unicode_from_string(space, self)
     return decode_object(space, self, encoding, errors)
Пример #2
0
 def unicode_w(self, space):
     # Use the default encoding.
     w_defaultencoding = space.call_function(space.sys.get(
                                             'getdefaultencoding'))
     encoding, errors = _get_encoding_and_errors(space, w_defaultencoding,
                                                 space.w_None)
     if encoding is None and errors is None:
         return space.unicode_w(unicode_from_string(space, self))
     return space.unicode_w(decode_object(space, self, encoding, errors))
Пример #3
0
 def unicode_w(self, space):
     # Use the default encoding.
     w_defaultencoding = space.call_function(space.sys.get(
                                             'getdefaultencoding'))
     encoding, errors = _get_encoding_and_errors(space, w_defaultencoding,
                                                 space.w_None)
     if encoding is None and errors is None:
         return space.unicode_w(unicode_from_string(space, self))
     return space.unicode_w(decode_object(space, self, encoding, errors))
Пример #4
0
    def descr_decode(self, space, w_encoding=None, w_errors=None):
        from pypy.objspace.std.unicodeobject import (
            _get_encoding_and_errors, decode_object, unicode_from_string)
        encoding, errors = _get_encoding_and_errors(space, w_encoding,
                                                    w_errors)

        from pypy.objspace.std.bytearrayobject import W_BytearrayObject
        if (encoding is None and errors is None and
            not isinstance(self, W_BytearrayObject)):
            return unicode_from_string(space, self)
        return decode_object(space, self, encoding, errors)
Пример #5
0
 def descr_decode(self, space, w_encoding=None, w_errors=None):
     from pypy.objspace.std.unicodeobject import (
         get_encoding_and_errors, decode_object)
     encoding, errors = get_encoding_and_errors(space, w_encoding, w_errors)
     if encoding is None:
         encoding = 'utf8'
     if encoding == 'utf8' or encoding == 'utf-8':
         # fast path - do not call into app-level codecs.py
         from pypy.module._codecs.interp_codecs import CodecState
         state = space.fromcache(CodecState)
         eh = state.decode_error_handler
         s = space.charbuf_w(self)
         ret, lgt, pos = str_decode_utf8(s, errors, True, eh)
         return space.newtext(ret, lgt)
     return decode_object(space, self, encoding, errors)
Пример #6
0
 def unicode_w(self, space):
     # Use the default encoding.
     encoding = getdefaultencoding(space)
     return space.unicode_w(decode_object(space, self, encoding, None))
Пример #7
0
 def descr_decode(self, space, w_encoding=None, w_errors=None):
     from pypy.objspace.std.unicodeobject import (_get_encoding_and_errors,
                                                  decode_object)
     encoding, errors = _get_encoding_and_errors(space, w_encoding,
                                                 w_errors)
     return decode_object(space, self, encoding, errors)
Пример #8
0
 def unicode_w(self, space):
     # Use the default encoding.
     encoding = getdefaultencoding(space)
     return space.unicode_w(decode_object(space, self, encoding, None))
Пример #9
0
 def descr_decode(self, space, w_encoding=None, w_errors=None):
     from pypy.objspace.std.unicodeobject import (
         _get_encoding_and_errors, decode_object)
     encoding, errors = _get_encoding_and_errors(space, w_encoding,
                                                 w_errors)
     return decode_object(space, self, encoding, errors)