Author: Matti Picus <matti.pi...@gmail.com>
Branch: unicode-utf8
Changeset: r95544:cc42e48c8a51
Date: 2018-12-26 08:20 +0200
http://bitbucket.org/pypy/pypy/changeset/cc42e48c8a51/

Log:    bytes.__mod__(unicode) must decode bytes as ascii

diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -11,6 +11,7 @@
 from rpython.tool.sourcetools import func_with_new_name
 
 from pypy.interpreter.error import OperationError, oefmt
+from pypy.interpreter.unicodehelper import check_ascii_or_raise
 
 
 class BaseStringFormatter(object):
@@ -435,15 +436,7 @@
             if not do_unicode:
                 if got_unicode:
                     # Make sure the format string is ascii encodable
-                    try:
-                        self.fmt.decode('ascii')
-                    except UnicodeDecodeError as e:
-                        raise OperationError(space.w_UnicodeDecodeError,
-                            space.newtuple([space.newtext('ascii'),
-                                            space.newbytes(self.fmt),
-                                            space.newint(e.start),
-                                            space.newint(e.end),
-                                            space.newtext(e.message)]))
+                    check_ascii_or_raise(space, self.fmt)
                     raise NeedUnicodeFormattingError
                 s = self.string_formatting(w_value)
             else:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to