Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r94999:51e9202ee008
Date: 2018-08-12 14:14 -0700
http://bitbucket.org/pypy/pypy/changeset/51e9202ee008/
Log: do not special-case surrogateescape
diff --git a/pypy/interpreter/unicodehelper.py
b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -27,8 +27,6 @@
space.newint(startingpos),
space.newint(endingpos),
space.newtext(msg)]))
- # make annotator happy
- return '', 0
return raise_unicode_exception_decode
def decode_never_raise(errors, encoding, msg, s, startingpos, endingpos):
@@ -36,26 +34,6 @@
ux = ['\ux' + hex(ord(x))[2:].upper() for x in s[startingpos:endingpos]]
return ''.join(ux), endingpos
-def decode_surrogateescape(errors, encoding, msg, obj, start, end):
- consumed = 0
- replace = u''
- while consumed < 4 and consumed < end - start:
- c = ord(obj[start+consumed])
- if c < 128:
- # Refuse to escape ASCII bytes.
- break
- replace += unichr(0xdc00 + c)
- consumed += 1
- if not consumed:
- # codec complained about ASCII byte.
- raise OperationError(space.w_UnicodeDecodeError,
- space.newtuple([space.newtext(encoding),
- space.newbytes(obj),
- space.newint(start),
- space.newint(end),
- space.newtext(msg)]))
- return replace.encode('utf8'), start + consumed
-
@specialize.memo()
def encode_error_handler(space):
# Fast version of the "strict" errors handler.
diff --git a/pypy/objspace/std/unicodeobject.py
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -1234,12 +1234,7 @@
def decode_object(space, w_obj, encoding, errors='strict'):
assert errors is not None
assert encoding is not None
- if errors == 'surrogateescape':
- s = space.charbuf_w(w_obj)
- s, lgt, pos = unicodehelper.str_decode_utf8(s, errors, True,
- unicodehelper.decode_surrogateescape, True)
- return space.newutf8(s, pos)
- elif errors == 'strict':
+ if errors == 'strict':
if encoding == 'ascii':
s = space.charbuf_w(w_obj)
unicodehelper.check_ascii_or_raise(space, s)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit