Author: Matti Picus <matti.pi...@gmail.com> Branch: Changeset: r96104:9ece3d54c956 Date: 2019-02-20 09:04 +0200 http://bitbucket.org/pypy/pypy/changeset/9ece3d54c956/
Log: fix, use unicodehelper.wcharpsize2utf8 more widely diff --git a/pypy/interpreter/unicodehelper.py b/pypy/interpreter/unicodehelper.py --- a/pypy/interpreter/unicodehelper.py +++ b/pypy/interpreter/unicodehelper.py @@ -537,14 +537,14 @@ def wcharpsize2utf8(space, wcharp, size): """Safe version of rffi.wcharpsize2utf8. - Raises app-level ValueError if any wchar value is outside the valid + Raises app-level rutf8.OutOfRange if any wchar value is outside the valid codepoint range. """ try: return rffi.wcharpsize2utf8(wcharp, size) - except ValueError: + except rutf8.OutOfRange as e: raise oefmt(space.w_ValueError, - "character is not in range [U+0000; U+10ffff]") + "character %s is not in range [U+0000; U+10ffff]", 'U+%x' % e.code) # ____________________________________________________________ diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py --- a/pypy/module/cpyext/unicodeobject.py +++ b/pypy/module/cpyext/unicodeobject.py @@ -18,7 +18,6 @@ from pypy.module.cpyext.bytesobject import PyString_Check from pypy.module.sys.interp_encoding import setdefaultencoding from pypy.module._codecs.interp_codecs import CodecState -from pypy.interpreter import unicodehelper from pypy.objspace.std import unicodeobject import sys @@ -618,7 +617,7 @@ errors = None state = space.fromcache(CodecState) - result, _, length, byteorder = unicodehelper.str_decode_utf_32_helper( + result, _, length, byteorder = str_decode_utf_32_helper( string, errors, final=True, errorhandler=state.decode_error_handler, byteorder=byteorder) if pbyteorder is not None: @@ -641,7 +640,7 @@ Returns 0 on success, -1 on failure. """ - u = rffi.wcharpsize2utf8(s, length) + u = wcharpsize2utf8(space, s, length) if llerrors: errors = rffi.charp2str(llerrors) else: _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit