[pypy-commit] pypy unicode-utf8: raise for non-ascii.__mod__(unicode)
mattip
pypy.commits at gmail.com
Tue Jan 1 01:46:29 EST 2019
Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8
Changeset: r95542:d9ad50294bd6
Date: 2018-12-25 22:32 +0200
http://bitbucket.org/pypy/pypy/changeset/d9ad50294bd6/
Log: raise for non-ascii.__mod__(unicode)
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
@@ -434,6 +434,16 @@
got_unicode = space.isinstance_w(w_value, space.w_unicode)
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)]))
raise NeedUnicodeFormattingError
s = self.string_formatting(w_value)
else:
More information about the pypy-commit
mailing list