[pypy-commit] pypy utf8-io: Reapply b89046216269
rlamy
pypy.commits at gmail.com
Sat Nov 25 21:40:16 EST 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: utf8-io
Changeset: r93178:52a6abae06e4
Date: 2017-11-26 01:58 +0000
http://bitbucket.org/pypy/pypy/changeset/52a6abae06e4/
Log: Reapply b89046216269
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1760,6 +1760,10 @@
def utf8_w(self, w_obj):
return w_obj.utf8_w(self)
+ def unicode_w(self, w_obj):
+ # XXX: kill me!
+ return w_obj.utf8_w(self).decode('utf-8')
+
def convert_to_w_unicode(self, w_obj):
return w_obj.convert_to_w_unicode(self)
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -212,6 +212,12 @@
def newutf8(self, x, l, f):
return w_some_obj()
+ def new_from_utf8(self, a):
+ return w_some_obj()
+
+ def newunicode(self, a):
+ return w_some_obj()
+
newtext = newbytes
newtext_or_none = newbytes
newfilename = newbytes
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -367,10 +367,23 @@
assert isinstance(utf8s, str)
return W_UnicodeObject(utf8s, length, flag)
+ def new_from_utf8(self, utf8s):
+ # XXX: kill me!
+ assert isinstance(utf8s, str)
+ length, flag = rutf8.check_utf8(utf8s, True)
+ return W_UnicodeObject(utf8s, length, flag)
+
def newfilename(self, s):
assert isinstance(s, str) # on pypy3, this decodes the byte string
return W_BytesObject(s) # with the filesystem encoding
+ def newunicode(self, unistr):
+ # XXX: kill me!
+ assert isinstance(unistr, unicode)
+ utf8s = unistr.encode("utf-8")
+ length, flag = rutf8.check_utf8(utf8s, True)
+ return self.newutf8(utf8s, length, flag)
+
def type(self, w_obj):
jit.promote(w_obj.__class__)
return w_obj.getclass(self)
More information about the pypy-commit
mailing list