[pypy-commit] pypy py3.5: Fix for %s on bytes, otherwise it already works
arigo
pypy.commits at gmail.com
Wed Nov 9 11:45:20 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r88280:fd7154e68fb8
Date: 2016-11-09 17:44 +0100
http://bitbucket.org/pypy/pypy/changeset/fd7154e68fb8/
Log: Fix for %s on bytes, otherwise it already works
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
@@ -422,20 +422,18 @@
return space.str_w(w_result)
def fmt_s(self, w_value):
+ if not do_unicode:
+ # on bytes, %s is equivalent to %b
+ self.fmt_b(w_value)
+ return
space = self.space
- got_unicode = space.isinstance_w(w_value,
- space.w_unicode)
- if not do_unicode:
- if got_unicode:
- raise NeedUnicodeFormattingError
- s = self.string_formatting(w_value)
+ got_unicode = space.isinstance_w(w_value, space.w_unicode)
+ if not got_unicode:
+ w_value = space.call_function(space.w_unicode, w_value)
else:
- if not got_unicode:
- w_value = space.call_function(space.w_unicode, w_value)
- else:
- from pypy.objspace.std.unicodeobject import unicode_from_object
- w_value = unicode_from_object(space, w_value)
- s = space.unicode_w(w_value)
+ from pypy.objspace.std.unicodeobject import unicode_from_object
+ w_value = unicode_from_object(space, w_value)
+ s = space.unicode_w(w_value)
self.std_wp(s)
def fmt_r(self, w_value):
More information about the pypy-commit
mailing list