Author: Matti Picus <[email protected]>
Branch: unicode-utf8
Changeset: r95105:b2656c189d7f
Date: 2018-09-12 10:56 +0300
http://bitbucket.org/pypy/pypy/changeset/b2656c189d7f/
Log: rarely-used str_w should use ascii-encoding (used for space.bytes_w)
diff --git a/pypy/objspace/std/unicodeobject.py
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -87,7 +87,8 @@
return space.newint(uid)
def str_w(self, space):
- return space.text_w(space.str(self))
+ # Returns ascii-encoded str
+ return space.text_w(encode_object(space, self, 'ascii', 'strict'))
def utf8_w(self, space):
return self._utf8
@@ -1103,11 +1104,11 @@
encoding = getdefaultencoding(space)
if errors is None or errors == 'strict':
if encoding == 'ascii':
- s = space.charbuf_w(w_obj)
+ s = space.utf8_w(w_obj)
unicodehelper.check_ascii_or_raise(space, s)
return space.newutf8(s, len(s))
if encoding == 'utf-8' or encoding == 'utf8':
- s = space.charbuf_w(w_obj)
+ s = space.utf8_w(w_obj)
lgt = unicodehelper.check_utf8_or_raise(space, s)
return space.newutf8(s, lgt)
w_codecs = space.getbuiltinmodule("_codecs")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit