Author: Matti Picus <matti.pi...@gmail.com> Branch: py3.6 Changeset: r96066:51e9bde8332f Date: 2019-02-18 15:06 +0200 http://bitbucket.org/pypy/pypy/changeset/51e9bde8332f/
Log: turn UnicodeError while converting to decimal into ValueError, correct message diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py --- a/pypy/objspace/std/intobject.py +++ b/pypy/objspace/std/intobject.py @@ -913,7 +913,12 @@ return _from_intlike(space, w_inttype, w_obj) elif space.isinstance_w(w_value, space.w_unicode): from pypy.objspace.std.unicodeobject import unicode_to_decimal_w - b = unicode_to_decimal_w(space, w_value, allow_surrogates=True) + try: + b = unicode_to_decimal_w(space, w_value, allow_surrogates=True) + except Exception: + raise oefmt(space.w_ValueError, + 'invalid literal for int() with base 10: %R', + w_value) return _string_to_int_or_long(space, w_inttype, w_value, b) elif (space.isinstance_w(w_value, space.w_bytearray) or space.isinstance_w(w_value, space.w_bytes)): @@ -941,7 +946,12 @@ if space.isinstance_w(w_value, space.w_unicode): from pypy.objspace.std.unicodeobject import unicode_to_decimal_w - s = unicode_to_decimal_w(space, w_value, allow_surrogates=True) + try: + s = unicode_to_decimal_w(space, w_value, allow_surrogates=True) + except Exception: + raise oefmt(space.w_ValueError, + 'invalid literal for int() with base %d: %S', + base, w_value) elif (space.isinstance_w(w_value, space.w_bytes) or space.isinstance_w(w_value, space.w_bytearray)): s = space.charbuf_w(w_value) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit