[pypy-commit] pypy unicode-utf8-py3: utf_8 -> utf8_w, str_w -> text_w

mattip pypy.commits at gmail.com
Mon Jul 9 09:01:00 EDT 2018


Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8-py3
Changeset: r94836:88b5b1b85e78
Date: 2018-07-09 05:10 -0700
http://bitbucket.org/pypy/pypy/changeset/88b5b1b85e78/

Log:	utf_8 -> utf8_w, str_w -> text_w

diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -312,7 +312,7 @@
 
     def descr_set__qualname__(self, space, w_name):
         try:
-            self._qualname = space.utf_8(w_name)
+            self._qualname = space.utf8_w(w_name)
         except OperationError as e:
             if e.match(space, space.w_TypeError):
                 raise oefmt(space.w_TypeError,
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -206,7 +206,7 @@
         self.co_filename = '<builtin>/%s' % (basename,)
         self.w_filename = self.space.newfilename(self.co_filename)
 
-    co_names = property(lambda self: [self.space.str_w(w_name) for w_name in self.co_names_w]) # for trace
+    co_names = property(lambda self: [self.space.text_w(w_name) for w_name in self.co_names_w]) # for trace
 
     def signature(self):
         return self._signature
@@ -453,7 +453,7 @@
         space = self.space
         # co_name should be an identifier
         name = self.co_name.decode('utf-8')
-        fn = space.utf_8(self.w_filename)
+        fn = space.utf8_w(self.w_filename)
         return space.newtext(b'<code object %s at 0x%s, file "%s", line %d>' % (
             name, unicode(self.getaddrstring(space)), fn,
             -1 if self.co_firstlineno == 0 else self.co_firstlineno))
diff --git a/pypy/interpreter/test/test_appinterp.py b/pypy/interpreter/test/test_appinterp.py
--- a/pypy/interpreter/test/test_appinterp.py
+++ b/pypy/interpreter/test/test_appinterp.py
@@ -155,7 +155,7 @@
         w_mymod2 = MyModule(space2, space2.wrap('mymod'))
 
         w_str = space1.getattr(w_mymod1, space1.wrap("hi"))
-        assert space1.str_w(w_str) == "hello"
+        assert space1.text_w(w_str) == "hello"
 
 class TestMixedModuleUnfreeze:
     spaceconfig = dict(usemodules=('_socket',))
diff --git a/pypy/interpreter/test/test_argument.py b/pypy/interpreter/test/test_argument.py
--- a/pypy/interpreter/test/test_argument.py
+++ b/pypy/interpreter/test/test_argument.py
@@ -99,6 +99,9 @@
     def text_w(self, s):
         return self.utf8_w(s)
 
+    def utf8_w(self, s):
+        return s
+
     def len(self, x):
         return len(x)
 
@@ -668,14 +671,14 @@
         try:
             Arguments(space, [], w_stararg=space.wrap(42))
         except OperationError as e:
-            msg = space.str_w(space.str(e.get_w_value(space)))
+            msg = space.text_w(space.str(e.get_w_value(space)))
             assert msg == "argument after * must be an iterable, not int"
         else:
             assert 0, "did not raise"
         try:
             Arguments(space, [], w_starstararg=space.wrap(42))
         except OperationError as e:
-            msg = space.str_w(space.str(e.get_w_value(space)))
+            msg = space.text_w(space.str(e.get_w_value(space)))
             assert msg == "argument after ** must be a mapping, not int"
         else:
             assert 0, "did not raise"
diff --git a/pypy/interpreter/test/test_compiler.py b/pypy/interpreter/test/test_compiler.py
--- a/pypy/interpreter/test/test_compiler.py
+++ b/pypy/interpreter/test/test_compiler.py
@@ -664,7 +664,7 @@
         w_d = space.newdict()
         space.exec_(code, w_d, w_d)
         w_res = space.getitem(w_d, space.wrap('res'))
-        assert space.str_w(w_res) == "global value"
+        assert space.text_w(w_res) == "global value"
 
     def test_method_and_var(self):
         space = self.space
@@ -753,7 +753,7 @@
         ex = e.value
         space = self.space
         assert ex.match(space, space.w_SyntaxError)
-        assert 'hello_world' in space.str_w(space.str(ex.get_w_value(space)))
+        assert 'hello_world' in space.text_w(space.str(ex.get_w_value(space)))
 
     def test_del_None(self):
         snippet = '''if 1:
diff --git a/pypy/interpreter/test/test_error.py b/pypy/interpreter/test/test_error.py
--- a/pypy/interpreter/test/test_error.py
+++ b/pypy/interpreter/test/test_error.py
@@ -43,7 +43,7 @@
     val = operr.get_w_value(space)
     assert space.isinstance_w(val, space.w_AttributeError)
     w_repr = space.repr(val)
-    assert space.str_w(w_repr) == "AttributeError(\"no attribute 'foo'\",)"
+    assert space.text_w(w_repr) == "AttributeError(\"no attribute 'foo'\",)"
 
 def test_oefmt_T(space):
     operr = oefmt(space.w_AttributeError,
@@ -167,7 +167,7 @@
 def test_new_exception(space):
     w_error = new_exception_class(space, '_socket.error')
     assert w_error.getname(space) == u'error'
-    assert space.str_w(space.repr(w_error)) == "<class '_socket.error'>"
+    assert space.text_w(space.repr(w_error)) == "<class '_socket.error'>"
     operr = OperationError(w_error, space.wrap("message"))
     assert operr.match(space, w_error)
     assert operr.match(space, space.w_Exception)
diff --git a/pypy/interpreter/test/test_gateway.py b/pypy/interpreter/test/test_gateway.py
--- a/pypy/interpreter/test/test_gateway.py
+++ b/pypy/interpreter/test/test_gateway.py
@@ -204,7 +204,7 @@
         assert space.int_w(space.call_function(w_c, w_a, space.wrap(1))) == 1 + 2
         assert space.int_w(space.call_function(w_c, w_b, space.wrap(-10))) == -10 + 1
 
-        doc = space.str_w(space.getattr(w_c, space.wrap('__doc__')))
+        doc = space.text_w(space.getattr(w_c, space.wrap('__doc__')))
         assert doc == "This is a method"
 
         meth_with_default = gateway.interpindirect2app(
@@ -856,7 +856,7 @@
             except SystemError as e:
                 return str(e)
         """)
-        err = space.str_w(w_msg)
+        err = space.text_w(w_msg)
         assert ('unexpected internal exception (please '
                 'report a bug): UnexpectedException') in err
 
diff --git a/pypy/interpreter/test/test_objspace.py b/pypy/interpreter/test/test_objspace.py
--- a/pypy/interpreter/test/test_objspace.py
+++ b/pypy/interpreter/test/test_objspace.py
@@ -130,13 +130,13 @@
         w_object_doc = self.space.getattr(self.space.w_object, w("__doc__"))
         w_instance = self.space.appexec([], "(): return object()")
         w_doc = self.space.lookup(w_instance, "__doc__")
-        assert self.space.str_w(w_doc) == self.space.str_w(w_object_doc)
+        assert self.space.text_w(w_doc) == self.space.text_w(w_object_doc)
         assert self.space.lookup(w_instance, "gobbledygook") is None
         w_instance = self.space.appexec([], """():
             class Lookup(object):
                 "bla"
             return Lookup()""")
-        assert self.space.str_w(self.space.lookup(w_instance, "__doc__")) == "bla"
+        assert self.space.text_w(self.space.lookup(w_instance, "__doc__")) == "bla"
 
     def test_callable(self):
         def is_callable(w_obj):
@@ -404,9 +404,9 @@
         w_executable = space.wrap('executable')
         assert space.findattr(space.sys, w_executable) is None
         space.setattr(space.sys, w_executable, space.wrap('foobar'))
-        assert space.str_w(space.getattr(space.sys, w_executable)) == 'foobar'
+        assert space.text_w(space.getattr(space.sys, w_executable)) == 'foobar'
         space.startup()
-        assert space.str_w(space.getattr(space.sys, w_executable)) == 'foobar'
+        assert space.text_w(space.getattr(space.sys, w_executable)) == 'foobar'
 
     def test_interned_strings_are_weak(self):
         import weakref, gc, random
diff --git a/pypy/interpreter/test/test_typedef.py b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -200,7 +200,7 @@
         w_seen = space.newlist([])
         W_Level1(space)
         gc.collect(); gc.collect()
-        assert space.str_w(space.repr(w_seen)) == "[]"  # not called yet
+        assert space.text_w(space.repr(w_seen)) == "[]"  # not called yet
         ec = space.getexecutioncontext()
         self.space.user_del_action.perform(ec, None)
         assert space.unwrap(w_seen) == [1]   # called by user_del_action
diff --git a/pypy/module/_cffi_backend/test/test_c.py b/pypy/module/_cffi_backend/test/test_c.py
--- a/pypy/module/_cffi_backend/test/test_c.py
+++ b/pypy/module/_cffi_backend/test/test_c.py
@@ -76,7 +76,7 @@
                     path = None
                 else:
                     import ctypes.util
-                    path = ctypes.util.find_library(space.str_w(w_name))
+                    path = ctypes.util.find_library(space.text_w(w_name))
                 return space.appexec([space.wrap(path), w_is_global],
                 """(path, is_global):
                     import _cffi_backend
diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -55,7 +55,7 @@
     base_module_name = module_name.split('.')[-1]
     sources = []
     if w_extra_source is not None:
-        sources.append(space.str_w(w_extra_source))
+        sources.append(space.text_w(w_extra_source))
     kwargs = {}
     if w_extra_compile_args is not None:
         kwargs['extra_compile_args'] = space.unwrap(w_extra_compile_args)
diff --git a/pypy/module/pyexpat/interp_pyexpat.py b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -2,7 +2,6 @@
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.unicodehelper import encode_utf8
 from rpython.rlib import rgc, jit, rutf8
 from rpython.rlib.objectmodel import specialize
 from rpython.rtyper.lltypesystem import rffi, lltype
@@ -639,7 +638,7 @@
         """Parse(data[, isfinal])
 Parse XML data.  `isfinal' should be true at end of input."""
         if space.isinstance_w(w_data, space.w_unicode):
-            data = encode_utf8(space, w_data.utf8_w(space))
+            data = w_data.utf8_w(space)
             # Explicitly set UTF-8 encoding. Return code ignored.
             XML_SetEncoding(self.itself, "utf-8")
         else:
diff --git a/pypy/tool/pydis.py b/pypy/tool/pydis.py
--- a/pypy/tool/pydis.py
+++ b/pypy/tool/pydis.py
@@ -69,7 +69,7 @@
         if space is None:
             return [repr(c) for c in co.co_consts_w]
         
-        r = lambda x: space.str_w(space.repr(x))
+        r = lambda x: space.text_w(space.repr(x))
         return [r(c) for c in co.co_consts_w]
 
     def repr_with_space(self, space):


More information about the pypy-commit mailing list