Author: Armin Rigo <[email protected]>
Branch:
Changeset: r90208:3b6d1f077a95
Date: 2017-02-19 17:06 +0100
http://bitbucket.org/pypy/pypy/changeset/3b6d1f077a95/
Log: translation fix (mostly for tests)
diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -107,6 +107,12 @@
return u'', None, endingpos
raise UnicodeEncodeError(encoding, u, startingpos, endingpos, msg)
+def ll_unicode_error_decode(errors, encoding, msg, s, startingpos, endingpos):
+ raise UnicodeDecodeError(encoding, s, startingpos, endingpos, msg)
+
+def ll_unicode_error_encode(errors, encoding, msg, u, startingpos, endingpos):
+ raise UnicodeEncodeError(encoding, u, startingpos, endingpos, msg)
+
# ____________________________________________________________
# utf-8
@@ -143,8 +149,8 @@
size = NonConstant(12345)
errors = NonConstant('strict')
final = NonConstant(True)
- errorhandler = default_unicode_error_decode
- allow_surrogates = NonConstant(False)
+ errorhandler = ll_unicode_error_decode
+ allow_surrogates = NonConstant(True)
return str_decode_utf_8_elidable(s, size, errors, final, errorhandler,
allow_surrogates=allow_surrogates)
@@ -359,8 +365,8 @@
s = NonConstant(u'?????')
size = NonConstant(12345)
errors = NonConstant('strict')
- errorhandler = default_unicode_error_encode
- allow_surrogates = NonConstant(False)
+ errorhandler = ll_unicode_error_encode
+ allow_surrogates = NonConstant(True)
return unicode_encode_utf_8_elidable(s, size, errors, errorhandler,
allow_surrogates=allow_surrogates)
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -23,7 +23,7 @@
from rpython.rlib import runicode
value = hlstr(llvalue)
assert value is not None
- errorhandler = runicode.default_unicode_error_decode
+ errorhandler = runicode.ll_unicode_error_decode
u, pos = runicode.str_decode_utf_8_elidable(
value, len(value), 'strict', True, errorhandler, True)
# XXX maybe the whole ''.decode('utf-8') should be not RPython.
@@ -390,7 +390,7 @@
from rpython.rlib import runicode
s = hlunicode(ll_s)
assert s is not None
- errorhandler = runicode.default_unicode_error_encode
+ errorhandler = runicode.ll_unicode_error_encode
bytes = runicode.unicode_encode_utf_8_elidable(
s, len(s), 'strict',
errorhandler=errorhandler, allow_surrogates=True)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit