aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2018-09-16 21:22:43 +0300
committerMatti Picus <matti.picus@gmail.com>2018-09-16 21:22:43 +0300
commit8bb02866a3c1ac1f43a565769ec81e92ede02d7e (patch)
treed9de30098f40711e7f7d9e00255d8e7609636099 /pypy/objspace/std/unicodeobject.py
parentfix off-by-one (diff)
downloadpypy-8bb02866a3c1ac1f43a565769ec81e92ede02d7e.tar.gz
pypy-8bb02866a3c1ac1f43a565769ec81e92ede02d7e.tar.bz2
pypy-8bb02866a3c1ac1f43a565769ec81e92ede02d7e.zip
fix some tests
Diffstat (limited to 'pypy/objspace/std/unicodeobject.py')
-rw-r--r--pypy/objspace/std/unicodeobject.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
index c3b23f64b7..b791fdae3b 100644
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -87,8 +87,7 @@ class W_UnicodeObject(W_Root):
return space.newint(uid)
def str_w(self, space):
- # Returns ascii-encoded str
- return space.text_w(encode_object(space, self, 'ascii', 'strict'))
+ return space.text_w(encode_object(space, self, 'utf8', 'strict'))
def utf8_w(self, space):
return self._utf8
@@ -110,7 +109,9 @@ class W_UnicodeObject(W_Root):
raise oefmt(space.w_TypeError,
"cannot use unicode as modifiable buffer")
- charbuf_w = str_w
+ def charbuf_w(self, space):
+ # Returns ascii-encoded str
+ return space.text_w(encode_object(space, self, 'ascii', 'strict'))
def listview_utf8(self):
assert self.is_ascii()
@@ -1106,11 +1107,11 @@ def decode_object(space, w_obj, encoding, errors):
encoding = getdefaultencoding(space)
if errors is None or errors == 'strict':
if encoding == 'ascii':
- s = space.utf8_w(w_obj)
+ s = space.charbuf_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.utf8_w(w_obj)
+ s = space.charbuf_w(w_obj)
lgt = unicodehelper.check_utf8_or_raise(space, s)
return space.newutf8(s, lgt)
w_codecs = space.getbuiltinmodule("_codecs")