Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r94971:a3b31b84b094
Date: 2018-08-07 09:48 -0700
http://bitbucket.org/pypy/pypy/changeset/a3b31b84b094/
Log: add partial implementation for interp_codecs
diff --git a/pypy/interpreter/unicodehelper.py
b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -225,8 +225,13 @@
# cannot be ASCII, cannot have surrogates, I believe
return res.build(), len(s), len(s)
-def utf8_encode_utf_8(s, errors, errorhandler):
- # needed by tests
+def utf8_encode_utf_8(s, errors, errorhandler, allow_surrogates=False):
+ # XXX completly implement this
+ try:
+ lgt = rutf8.check_utf8(s, allow_surrogates=allow_surrogates)
+ except rutf8.CheckError as e:
+ s, lgt = errorhandler(errors, 'encoding',
+ 'surrogates not allowed', s, e.pos, e.pos + 1)
return s
def utf8_encode_latin_1(s, errors, errorhandler):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit