Author: Carl Friedrich Bolz <[email protected]>
Branch: space-newtext
Changeset: r88775:ffe62ff416aa
Date: 2016-11-30 16:26 +0100
http://bitbucket.org/pypy/pypy/changeset/ffe62ff416aa/

Log:    start replacing space.str_w with either space.bytes_w or
        space.text_w

diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -71,7 +71,7 @@
             except OperationError as e:
                 debug("OperationError:")
                 debug(" operror-type: " + e.w_type.getname(space))
-                debug(" operror-value: " + 
space.str_w(space.str(e.get_w_value(space))))
+                debug(" operror-value: " + 
space.text_w(space.str(e.get_w_value(space))))
                 return 1
         finally:
             try:
@@ -79,7 +79,7 @@
             except OperationError as e:
                 debug("OperationError:")
                 debug(" operror-type: " + e.w_type.getname(space))
-                debug(" operror-value: " + 
space.str_w(space.str(e.get_w_value(space))))
+                debug(" operror-value: " + 
space.text_w(space.str(e.get_w_value(space))))
                 return 1
         return exitcode
 
@@ -130,7 +130,7 @@
             if verbose:
                 debug("OperationError:")
                 debug(" operror-type: " + e.w_type.getname(space))
-                debug(" operror-value: " + 
space.str_w(space.str(e.get_w_value(space))))
+                debug(" operror-value: " + 
space.text_w(space.str(e.get_w_value(space))))
             return rffi.cast(rffi.INT, -1)
         finally:
             if must_leave:
@@ -184,7 +184,7 @@
         except OperationError as e:
             debug("OperationError:")
             debug(" operror-type: " + e.w_type.getname(space))
-            debug(" operror-value: " + 
space.str_w(space.str(e.get_w_value(space))))
+            debug(" operror-value: " + 
space.text_w(space.str(e.get_w_value(space))))
             return -1
         return 0
 
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -77,7 +77,8 @@
 
     def getname(self, space):
         try:
-            return space.str_w(space.getattr(self, space.newtext('__name__')))
+            # YYY should be text_w?
+            return space.bytes_w(space.getattr(self, 
space.newtext('__name__')))
         except OperationError as e:
             if e.match(space, space.w_TypeError) or e.match(space, 
space.w_AttributeError):
                 return '?'
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -64,7 +64,7 @@
             if self.__class__ is not OperationError and s is None:
                 s = self._compute_value(space)
             try:
-                s = space.str_w(s)
+                s = space.text_w(s)
             except Exception:
                 pass
         return '[%s: %s]' % (self.w_type, s)
@@ -77,16 +77,16 @@
             exc_typename = str(self.w_type)
             exc_value = str(w_value)
         else:
-            exc_typename = space.str_w(
+            exc_typename = space.text_w(
                     space.getattr(self.w_type, space.newtext('__name__')))
             if space.is_w(w_value, space.w_None):
                 exc_value = ""
             else:
                 try:
                     if use_repr:
-                        exc_value = space.str_w(space.repr(w_value))
+                        exc_value = space.text_w(space.repr(w_value))
                     else:
-                        exc_value = space.str_w(space.str(w_value))
+                        exc_value = space.text_w(space.str(w_value))
                 except OperationError:
                     # oups, cannot __str__ the exception object
                     exc_value = ("<exception %s() failed>" %
@@ -238,7 +238,7 @@
             objrepr = ''
         else:
             try:
-                objrepr = space.str_w(space.repr(w_object))
+                objrepr = space.text_w(space.repr(w_object))
             except OperationError:
                 objrepr = "<object repr() failed>"
         #
@@ -364,7 +364,7 @@
                     lst[i + i] = self.xstrings[i]
                     value = getattr(self, attr)
                     if fmt == 'R':
-                        result = space.str_w(space.repr(value))
+                        result = space.text_w(space.repr(value))
                     elif fmt == 'T':
                         result = space.type(value).name
                     elif fmt == 'N':
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -213,7 +213,7 @@
         if not space.isinstance_w(w_globals, space.w_dict):
             raise oefmt(space.w_TypeError, "expected dict")
         if not space.is_none(w_name):
-            name = space.str_w(w_name)
+            name = space.text_w(w_name)
         else:
             name = None
         if not space.is_none(w_argdefs):
@@ -377,8 +377,8 @@
         return space.newtext(self.name)
 
     def fset_func_name(self, space, w_name):
-        if space.isinstance_w(w_name, space.w_str):
-            self.name = space.str_w(w_name)
+        if space.isinstance_w(w_name, space.w_text):
+            self.name = space.text_w(w_name)
         else:
             raise oefmt(space.w_TypeError,
                         "__name__ must be set to a string object")
@@ -529,13 +529,13 @@
             s = "<unbound method %s.%s>" % (typename, name)
             return space.newtext(s)
         else:
-            objrepr = space.str_w(space.repr(self.w_instance))
+            objrepr = space.text_w(space.repr(self.w_instance))
             s = '<bound method %s.%s of %s>' % (typename, name, objrepr)
             return space.newtext(s)
 
     def descr_method_getattribute(self, w_attr):
         space = self.space
-        if space.str_w(w_attr) != '__doc__':
+        if space.text_w(w_attr) != '__doc__':
             try:
                 return space.call_method(space.w_object, '__getattribute__',
                                          self, w_attr)
diff --git a/pypy/interpreter/module.py b/pypy/interpreter/module.py
--- a/pypy/interpreter/module.py
+++ b/pypy/interpreter/module.py
@@ -122,14 +122,14 @@
     def descr_module__repr__(self, space):
         from pypy.interpreter.mixedmodule import MixedModule
         if self.w_name is not None:
-            name = space.str_w(space.repr(self.w_name))
+            name = space.text_w(space.repr(self.w_name))
         else:
             name = "'?'"
         if isinstance(self, MixedModule):
             return space.newtext("<module %s (built-in)>" % name)
         try:
             w___file__ = space.getattr(self, space.newtext('__file__'))
-            __file__ = space.str_w(space.repr(w___file__))
+            __file__ = space.text_w(space.repr(w___file__))
         except OperationError:
             __file__ = '?'
         return space.newtext("<module %s from %s>" % (name, __file__))
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -848,8 +848,8 @@
             # catch KeyErrors and turn them into NameErrors
             if not e.match(self.space, self.space.w_KeyError):
                 raise
-            raise oefmt(self.space.w_NameError, "name '%s' is not defined",
-                        self.space.str_w(w_varname))
+            raise oefmt(self.space.w_NameError, "name %R is not defined",
+                        w_varname)
 
     def UNPACK_SEQUENCE(self, itemcount, next_instr):
         w_iterable = self.popvalue()
@@ -996,7 +996,6 @@
     def IMPORT_NAME(self, nameindex, next_instr):
         space = self.space
         w_modulename = self.getname_w(nameindex)
-        modulename = self.space.str_w(w_modulename)
         w_fromlist = self.popvalue()
 
         w_flag = self.popvalue()
@@ -1018,7 +1017,6 @@
             w_locals = d.w_locals
         if w_locals is None:            # CPython does this
             w_locals = space.w_None
-        w_modulename = space.newtext(modulename)
         w_globals = self.get_w_globals()
         if w_flag is None:
             w_obj = space.call_function(w_import, w_modulename, w_globals,
@@ -1044,7 +1042,7 @@
             if not e.match(self.space, self.space.w_AttributeError):
                 raise
             raise oefmt(self.space.w_ImportError,
-                        "cannot import name '%s'", self.space.str_w(w_name))
+                        "cannot import name %R", w_name)
         self.pushvalue(w_obj)
 
     def YIELD_VALUE(self, oparg, next_instr):
@@ -1177,7 +1175,7 @@
                     break
                 w_value = self.popvalue()
                 w_key = self.popvalue()
-                key = self.space.str_w(w_key)
+                key = self.space.text_w(w_key)
                 keywords[n_keywords] = key
                 keywords_w[n_keywords] = w_value
         else:
diff --git a/pypy/module/__builtin__/descriptor.py 
b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -41,7 +41,7 @@
             return space.call_function(w_selftype, self.w_starttype, w_obj)
 
     def getattribute(self, space, w_name):
-        name = space.str_w(w_name)
+        name = space.text_w(w_name)
         # only use a special logic for bound super objects and not for
         # getting the __class__ of the super object itself.
         if self.w_objtype is not None and name != '__class__':
diff --git a/pypy/module/__builtin__/interp_classobj.py 
b/pypy/module/__builtin__/interp_classobj.py
--- a/pypy/module/__builtin__/interp_classobj.py
+++ b/pypy/module/__builtin__/interp_classobj.py
@@ -42,7 +42,7 @@
     _immutable_fields_ = ['bases_w?[*]', 'w_dict?']
 
     def __init__(self, space, w_name, bases, w_dict):
-        self.name = space.str_w(w_name)
+        self.name = space.text_w(w_name)
         make_sure_not_resized(bases)
         self.bases_w = bases
         self.w_dict = w_dict
@@ -66,7 +66,7 @@
     def setname(self, space, w_newname):
         if not space.isinstance_w(w_newname, space.w_str):
             raise oefmt(space.w_TypeError, "__name__ must be a string object")
-        self.name = space.str_w(w_newname)
+        self.name = space.text_w(w_newname)
 
     def setbases(self, space, w_bases):
         if not space.isinstance_w(w_bases, space.w_tuple):
@@ -123,7 +123,7 @@
         return space.call_function(w_descr_get, w_value, space.w_None, self)
 
     def descr_setattr(self, space, w_attr, w_value):
-        name = space.str_w(w_attr)
+        name = space.text_w(w_attr)
         if name and name[0] == "_":
             if name == "__dict__":
                 self.setdict(space, w_value)
@@ -142,7 +142,7 @@
         space.setitem(self.w_dict, w_attr, w_value)
 
     def descr_delattr(self, space, w_attr):
-        name = space.str_w(w_attr)
+        name = space.text_w(w_attr)
         if name in ("__dict__", "__name__", "__bases__"):
             raise oefmt(space.w_TypeError,
                         "cannot delete attribute '%s'", name)
@@ -173,7 +173,7 @@
                 raise
             return "?"
         if space.isinstance_w(w_mod, space.w_str):
-            return space.str_w(w_mod)
+            return space.text_w(w_mod)
         return "?"
 
     def __repr__(self):
@@ -361,7 +361,7 @@
         return self.getattr(space, name)
 
     def descr_setattr(self, space, w_name, w_value):
-        name = space.str_w(w_name)
+        name = space.text_w(w_name)
         w_meth = self.getattr_from_class(space, '__setattr__')
         if name and name[0] == "_":
             if name == '__dict__':
@@ -382,7 +382,7 @@
             self.setdictvalue(space, name, w_value)
 
     def descr_delattr(self, space, w_name):
-        name = space.str_w(w_name)
+        name = space.text_w(w_name)
         if name and name[0] == "_":
             if name == '__dict__':
                 # use setdict to raise the error
diff --git a/pypy/module/__builtin__/operation.py 
b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -45,7 +45,7 @@
     # Note that if w_name is already an exact string it must be returned
     # unmodified (and not e.g. unwrapped-rewrapped).
     if not space.is_w(space.type(w_name), space.w_str):
-        name = space.str_w(w_name)    # typecheck
+        name = space.text_w(w_name)    # typecheck
         w_name = space.newtext(name)     # rewrap as a real string
     return w_name
 
diff --git a/pypy/module/_codecs/interp_codecs.py 
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -309,7 +309,7 @@
     if w_encoding is None:
         encoding = space.sys.defaultencoding
     else:
-        encoding = space.str_w(w_encoding)
+        encoding = space.text_w(w_encoding)
     w_encoder = space.getitem(lookup_codec(space, encoding), space.newint(0))
     w_res = space.call_function(w_encoder, w_obj, space.newtext(errors))
     return space.getitem(w_res, space.newint(0))
@@ -338,7 +338,7 @@
     if w_encoding is None:
         encoding = space.sys.defaultencoding
     else:
-        encoding = space.str_w(w_encoding)
+        encoding = space.text_w(w_encoding)
     w_decoder = space.getitem(lookup_codec(space, encoding), space.newint(1))
     if space.is_true(w_decoder):
         w_res = space.call_function(w_decoder, w_obj, space.newtext(errors))
diff --git a/pypy/module/_csv/interp_reader.py 
b/pypy/module/_csv/interp_reader.py
--- a/pypy/module/_csv/interp_reader.py
+++ b/pypy/module/_csv/interp_reader.py
@@ -79,7 +79,7 @@
                             break
                 raise
             self.line_num += 1
-            line = space.str_w(w_line)
+            line = space.text_w(w_line)
             for c in line:
                 if c == '\0':
                     raise self.error("line contains NULL byte")
diff --git a/pypy/module/_locale/interp_locale.py 
b/pypy/module/_locale/interp_locale.py
--- a/pypy/module/_locale/interp_locale.py
+++ b/pypy/module/_locale/interp_locale.py
@@ -51,7 +51,7 @@
     if space.is_none(w_locale):
         locale = None
     else:
-        locale = space.str_w(w_locale)
+        locale = space.text_w(w_locale)
     try:
         result = rlocale.setlocale(category, locale)
     except rlocale.LocaleError as e:
@@ -121,10 +121,10 @@
 def strcoll(space, w_s1, w_s2):
     "string,string -> int. Compares two strings according to the locale."
 
-    if (space.isinstance_w(w_s1, space.w_str) and
-        space.isinstance_w(w_s2, space.w_str)):
+    if (space.isinstance_w(w_s1, space.w_bytes) and
+        space.isinstance_w(w_s2, space.w_bytes)):
 
-        s1, s2 = space.str_w(w_s1), space.str_w(w_s2)
+        s1, s2 = space.bytes_w(w_s1), space.bytes_w(w_s2)
         s1_c = rffi.str2charp(s1)
         s2_c = rffi.str2charp(s2)
         try:
@@ -221,7 +221,7 @@
             finally:
                 rffi.free_charp(msg_c)
         else:
-            domain = space.str_w(w_domain)
+            domain = space.text_w(w_domain)
             domain_c = rffi.str2charp(domain)
             msg_c = rffi.str2charp(msg)
             try:
@@ -256,7 +256,7 @@
             finally:
                 rffi.free_charp(msg_c)
         else:
-            domain = space.str_w(w_domain)
+            domain = space.text_w(w_domain)
             domain_c = rffi.str2charp(domain)
             msg_c = rffi.str2charp(msg)
             try:
@@ -284,7 +284,7 @@
             result = _textdomain(domain)
             result = rffi.charp2str(result)
         else:
-            domain = space.str_w(w_domain)
+            domain = space.text_w(w_domain)
             domain_c = rffi.str2charp(domain)
             try:
                 result = _textdomain(domain_c)
@@ -314,7 +314,7 @@
             finally:
                 rffi.free_charp(domain_c)
         else:
-            dir = space.str_w(w_dir)
+            dir = space.text_w(w_dir)
             domain_c = rffi.str2charp(domain)
             dir_c = rffi.str2charp(dir)
             try:
@@ -345,7 +345,7 @@
                 finally:
                     rffi.free_charp(domain_c)
             else:
-                codeset = space.str_w(w_codeset)
+                codeset = space.text_w(w_codeset)
                 domain_c = rffi.str2charp(domain)
                 codeset_c = rffi.str2charp(codeset)
                 try:
diff --git a/pypy/module/_lsprof/interp_lsprof.py 
b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -49,11 +49,11 @@
         return self.w_calls
 
     def repr(self, space):
-        frame_repr = space.str_w(space.repr(self.frame))
+        frame_repr = space.text_w(space.repr(self.frame))
         if not self.w_calls:
             calls_repr = "None"
         else:
-            calls_repr = space.str_w(space.repr(self.w_calls))
+            calls_repr = space.text_w(space.repr(self.w_calls))
         return space.newtext('("%s", %d, %d, %f, %f, %s)' % (
             frame_repr, self.callcount, self.reccallcount,
             self.tt, self.it, calls_repr))
@@ -85,7 +85,7 @@
         self.tt = tt
 
     def repr(self, space):
-        frame_repr = space.str_w(space.repr(self.frame))
+        frame_repr = space.text_w(space.repr(self.frame))
         return space.newtext('("%s", %d, %d, %f, %f)' % (
             frame_repr, self.callcount, self.reccallcount, self.tt, self.it))
 
@@ -218,7 +218,7 @@
 def create_spec_for_function(space, w_func):
     assert isinstance(w_func, Function)
     if w_func.w_module is not None:
-        module = space.str_w(w_func.w_module)
+        module = space.text_w(w_func.w_module)
         if module != '__builtin__':
             return '<%s.%s>' % (module, w_func.name)
     return '<%s>' % w_func.name
@@ -233,7 +233,7 @@
     # This class should not be seen at app-level, but is useful to
     # contain a (w_func, w_type) pair returned by prepare_spec().
     # Turning this pair into a string cannot be done eagerly in
-    # an @elidable function because of space.str_w(), but it can
+    # an @elidable function because of space.text_w(), but it can
     # be done lazily when we really want it.
 
     _immutable_fields_ = ['w_func', 'w_type']
diff --git a/pypy/module/_minimal_curses/interp_curses.py 
b/pypy/module/_minimal_curses/interp_curses.py
--- a/pypy/module/_minimal_curses/interp_curses.py
+++ b/pypy/module/_minimal_curses/interp_curses.py
@@ -51,7 +51,7 @@
         if space.is_none(w_termname):
             _curses_setupterm_null(fd)
         else:
-            _curses_setupterm(space.str_w(w_termname), fd)
+            _curses_setupterm(space.text_w(w_termname), fd)
     except curses_error as e:
         raise convert_error(space, e)
 
diff --git a/pypy/module/_multibytecodec/interp_incremental.py 
b/pypy/module/_multibytecodec/interp_incremental.py
--- a/pypy/module/_multibytecodec/interp_incremental.py
+++ b/pypy/module/_multibytecodec/interp_incremental.py
@@ -33,7 +33,7 @@
         return space.newtext(self.errors)
 
     def fset_errors(self, space, w_errors):
-        self.errors = space.str_w(w_errors)
+        self.errors = space.text_w(w_errors)
 
 
 class MultibyteIncrementalDecoder(MultibyteIncrementalBase):
diff --git a/pypy/module/_multiprocessing/interp_connection.py 
b/pypy/module/_multiprocessing/interp_connection.py
--- a/pypy/module/_multiprocessing/interp_connection.py
+++ b/pypy/module/_multiprocessing/interp_connection.py
@@ -156,7 +156,7 @@
         w_pickled = space.call_method(
             w_picklemodule, "dumps", w_obj, w_protocol)
 
-        buf = space.str_w(w_pickled)
+        buf = space.bytes_w(w_pickled)
         self.do_send_string(space, buf, 0, len(buf))
 
     def recv(self, space):
diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -1432,11 +1432,11 @@
         if space.is_none(w_certfile):
             certfile = None
         else:
-            certfile = space.str_w(w_certfile)
+            certfile = space.text_w(w_certfile)
         if space.is_none(w_keyfile):
             keyfile = certfile
         else:
-            keyfile = space.str_w(w_keyfile)
+            keyfile = space.text_w(w_keyfile)
         pw_info = PasswordInfo()
         pw_info.space = space
         index = -1
@@ -1529,11 +1529,11 @@
         if space.is_none(w_cafile):
             cafile = None
         else:
-            cafile = space.str_w(w_cafile)
+            cafile = space.text_w(w_cafile)
         if space.is_none(w_capath):
             capath = None
         else:
-            capath = space.str_w(w_capath)
+            capath = space.text_w(w_capath)
         if space.is_none(w_cadata):
             cadata = None
             ca_file_type = -1
diff --git a/pypy/module/_warnings/interp_warnings.py 
b/pypy/module/_warnings/interp_warnings.py
--- a/pypy/module/_warnings/interp_warnings.py
+++ b/pypy/module/_warnings/interp_warnings.py
@@ -101,9 +101,9 @@
     # setup filename
     try:
         w_filename = space.getitem(w_globals, space.newtext("__file__"))
-        filename = space.str_w(w_filename)
+        filename = space.text_w(w_filename)
     except OperationError as e:
-        if space.str_w(w_module) == '__main__':
+        if space.text_w(w_module) == '__main__':
             w_argv = space.sys.getdictvalue(space, 'argv')
             if w_argv and space.len_w(w_argv) > 0:
                 w_filename = space.getitem(w_argv, space.newint(0))
@@ -145,7 +145,7 @@
             check_matched(space, w_mod, w_module) and
             space.abstract_issubclass_w(w_category, w_cat) and
             (ln == 0 or ln == lineno)):
-            return space.str_w(w_action), w_item
+            return space.text_w(w_action), w_item
 
     action = get_default_action(space)
     if not action:
@@ -155,10 +155,10 @@
 def get_default_action(space):
     w_action = get_warnings_attr(space, "defaultaction");
     if w_action is None:
-        return space.str_w(space.fromcache(State).w_default_action)
+        return space.text_w(space.fromcache(State).w_default_action)
 
     space.fromcache(State).w_default_action = w_action
-    return space.str_w(w_action)
+    return space.text_w(w_action)
 
 def get_once_registry(space):
     w_registry = get_warnings_attr(space, "onceregistry");
@@ -188,7 +188,7 @@
     if not space.is_true(w_filename):
         return space.newtext("<unknown>")
 
-    filename = space.str_w(w_filename)
+    filename = space.text_w(w_filename)
     if filename.endswith(".py"):
         n = len(filename) - 3
         assert n >= 0
@@ -201,8 +201,8 @@
     w_stderr = space.sys.get("stderr")
 
     # Print "filename:lineno: category: text\n"
-    message = "%s:%d: %s: %s\n" % (space.str_w(w_filename), lineno,
-                                   space.str_w(w_name), space.str_w(w_text))
+    message = "%s:%d: %s: %s\n" % (space.text_w(w_filename), lineno,
+                                   space.text_w(w_name), space.text_w(w_text))
     space.call_method(w_stderr, "write", space.newtext(message))
 
     # Print "  source_line\n"
@@ -220,7 +220,7 @@
 
     if not w_sourceline:
         return
-    line = space.str_w(w_sourceline)
+    line = space.text_w(w_sourceline)
     if not line:
         return
 
@@ -288,7 +288,7 @@
                 warned = update_registry(space, w_registry, w_text, w_category)
         elif action != 'default':
             try:
-                err = space.str_w(space.str(w_item))
+                err = space.text_w(space.str(w_item))
             except OperationError:
                 err = "???"
             raise oefmt(space.w_RuntimeError,
diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -477,15 +477,15 @@
             return space.newtext("array('%s')" % self.typecode)
         elif self.typecode == "c":
             r = space.repr(self.descr_tostring(space))
-            s = "array('%s', %s)" % (self.typecode, space.str_w(r))
+            s = "array('%s', %s)" % (self.typecode, space.text_w(r))
             return space.newtext(s)
         elif self.typecode == "u":
             r = space.repr(self.descr_tounicode(space))
-            s = "array('%s', %s)" % (self.typecode, space.str_w(r))
+            s = "array('%s', %s)" % (self.typecode, space.text_w(r))
             return space.newtext(s)
         else:
             r = space.repr(self.descr_tolist(space))
-            s = "array('%s', %s)" % (self.typecode, space.str_w(r))
+            s = "array('%s', %s)" % (self.typecode, space.text_w(r))
             return space.newtext(s)
 
 W_ArrayBase.typedef = TypeDef(
diff --git a/pypy/module/bz2/interp_bz2.py b/pypy/module/bz2/interp_bz2.py
--- a/pypy/module/bz2/interp_bz2.py
+++ b/pypy/module/bz2/interp_bz2.py
@@ -265,7 +265,8 @@
 
     _exposed_method_names = []
     W_File._decl.im_func(locals(), "bz2__init__",
-                         """Opens a BZ2-compressed file.""")
+                         """Opens a BZ2-compressed file.""",
+                         wrapresult="space.w_None")
     # XXX ^^^ hacking hacking... can't just use the name "__init__" again
     # because the RTyper is confused about the two direct__init__() with
     # a different signature, confusion caused by the fact that
@@ -315,6 +316,7 @@
     **dict([(name, W_File.typedef.rawdict[name])
             for name in same_attributes_as_in_file]))
 
+
 # ____________________________________________________________
 
 def open_bz2file_as_stream(space, w_path, mode="r", buffering=-1,
diff --git a/pypy/module/exceptions/interp_exceptions.py 
b/pypy/module/exceptions/interp_exceptions.py
--- a/pypy/module/exceptions/interp_exceptions.py
+++ b/pypy/module/exceptions/interp_exceptions.py
@@ -135,7 +135,7 @@
 
     def descr_repr(self, space):
         if self.args_w:
-            args_repr = space.str_w(space.repr(space.newtuple(self.args_w)))
+            args_repr = space.text_w(space.repr(space.newtuple(self.args_w)))
         else:
             args_repr = "()"
         clsname = self.getclass(space).getname(space)
@@ -381,13 +381,13 @@
     def descr_str(self, space):
         if (not space.is_w(self.w_errno, space.w_None) and
             not space.is_w(self.w_strerror, space.w_None)):
-            errno = space.str_w(space.str(self.w_errno))
-            strerror = space.str_w(space.str(self.w_strerror))
+            errno = space.text_w(space.str(self.w_errno))
+            strerror = space.text_w(space.str(self.w_strerror))
             if not space.is_w(self.w_filename, space.w_None):
                 return space.newtext("[Errno %s] %s: %s" % (
                     errno,
                     strerror,
-                    space.str_w(space.repr(self.w_filename))))
+                    space.text_w(space.repr(self.w_filename))))
             return space.newtext("[Errno %s] %s" % (
                 errno,
                 strerror,
@@ -436,10 +436,10 @@
             if not space.is_w(self.w_filename, space.w_None):
                 return space.newtext("[Error %d] %s: %s" % (
                     space.int_w(self.w_winerror),
-                    space.str_w(self.w_strerror),
-                    space.str_w(self.w_filename)))
+                    space.text_w(self.w_strerror),
+                    space.text_w(self.w_filename)))
             return space.newtext("[Error %d] %s" % 
(space.int_w(self.w_winerror),
-                                                    
space.str_w(self.w_strerror)))
+                                                    
space.text_w(self.w_strerror)))
         return W_BaseException.descr_str(self, space)
 
     if hasattr(rwin32, 'build_winerror_to_errno'):
@@ -547,7 +547,7 @@
             values_w = space.fixedview(self.args_w[1])
             w_tuple = space.newtuple(values_w + [self.w_lastlineno])
             args_w = [self.args_w[0], w_tuple]
-            args_repr = space.str_w(space.repr(space.newtuple(args_w)))
+            args_repr = space.text_w(space.repr(space.newtuple(args_w)))
             clsname = self.getclass(space).getname(space)
             return space.newtext(clsname + args_repr)
         else:
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -664,7 +664,7 @@
                         pass
                 return w_mod
             elif find_info.modtype == C_EXTENSION and has_so_extension(space):
-                load_c_extension(space, find_info.filename, 
space.str_w(w_modulename))
+                load_c_extension(space, find_info.filename, 
space.text_w(w_modulename))
                 return check_sys_modules(space, w_modulename)
         except OperationError:
             w_mods = space.sys.get('modules')
@@ -906,7 +906,7 @@
     """
 
     log_pyverbose(space, 1, "import %s # from %s\n" %
-                  (space.str_w(w_modulename), pathname))
+                  (space.text_w(w_modulename), pathname))
 
     src_stat = os.fstat(fd)
     cpathname = pathname + 'c'
@@ -1030,7 +1030,7 @@
     'sys.modules[modulename]', which must exist.
     """
     log_pyverbose(space, 1, "import %s # compiled from %s\n" %
-                  (space.str_w(w_modulename), cpathname))
+                  (space.text_w(w_modulename), cpathname))
 
     if magic != get_pyc_magic(space):
         raise oefmt(space.w_ImportError, "Bad magic number in %s", cpathname)
@@ -1069,7 +1069,7 @@
     try:
         w_str = space.call_method(w_marshal, 'dumps', co,
                                   space.newint(MARSHAL_VERSION_FOR_PYC))
-        strbuf = space.str_w(w_str)
+        strbuf = space.text_w(w_str)
     except OperationError as e:
         if e.async(space):
             raise
diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py
--- a/pypy/module/imp/interp_imp.py
+++ b/pypy/module/imp/interp_imp.py
@@ -79,7 +79,7 @@
     w_suffix, w_filemode, w_modtype = space.unpackiterable(w_info, 3)
 
     filename = space.str0_w(w_filename)
-    filemode = space.str_w(w_filemode)
+    filemode = space.text_w(w_filemode)
     if space.is_w(w_file, space.w_None):
         stream = None
     else:
@@ -89,7 +89,7 @@
         space.int_w(w_modtype),
         filename,
         stream,
-        space.str_w(w_suffix),
+        space.text_w(w_suffix),
         filemode)
     return importing.load_module(
         space, w_name, find_info, reuse=True)
@@ -136,7 +136,7 @@
 def load_dynamic(space, w_modulename, filename, w_file=None):
     if not importing.has_so_extension(space):
         raise oefmt(space.w_ImportError, "Not implemented")
-    importing.load_c_extension(space, filename, space.str_w(w_modulename))
+    importing.load_c_extension(space, filename, space.text_w(w_modulename))
     return importing.check_sys_modules(space, w_modulename)
 
 def new_module(space, w_name):
diff --git a/pypy/module/itertools/interp_itertools.py 
b/pypy/module/itertools/interp_itertools.py
--- a/pypy/module/itertools/interp_itertools.py
+++ b/pypy/module/itertools/interp_itertools.py
@@ -26,11 +26,11 @@
 
     def repr_w(self):
         space = self.space
-        c = space.str_w(space.repr(self.w_c))
+        c = space.text_w(space.repr(self.w_c))
         if self.single_argument():
             s = 'count(%s)' % (c,)
         else:
-            step = space.str_w(space.repr(self.w_step))
+            step = space.text_w(space.repr(self.w_step))
             s = 'count(%s, %s)' % (c, step)
         return self.space.newtext(s)
 
@@ -106,7 +106,7 @@
         return self.space.newint(self.count)
 
     def repr_w(self):
-        objrepr = self.space.str_w(self.space.repr(self.w_obj))
+        objrepr = self.space.text_w(self.space.repr(self.w_obj))
         if self.counting:
             s = 'repeat(%s, %d)' % (objrepr, self.count)
         else:
diff --git a/pypy/module/marshal/interp_marshal.py 
b/pypy/module/marshal/interp_marshal.py
--- a/pypy/module/marshal/interp_marshal.py
+++ b/pypy/module/marshal/interp_marshal.py
@@ -103,7 +103,7 @@
     def read(self, n):
         space = self.space
         w_ret = space.call_function(self.func, space.newint(n))
-        ret = space.str_w(w_ret)
+        ret = space.text_w(w_ret)
         if len(ret) != n:
             self.raise_eof()
         return ret
diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1222,7 +1222,7 @@
     # XXX slightly non-nice, reuses the sysconf of the underlying os module
     if space.isinstance_w(w_name, space.w_basestring):
         try:
-            num = namespace[space.str_w(w_name)]
+            num = namespace[space.text_w(w_name)]
         except KeyError:
             raise oefmt(space.w_ValueError, "unrecognized configuration name")
     else:
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
@@ -658,7 +658,7 @@
         eof = False
         while not eof:
             w_data = space.call_method(w_file, 'read', space.newint(2048))
-            data = space.str_w(w_data)
+            data = space.text_w(w_data)
             eof = len(data) == 0
             w_res = self.Parse(space, data, isfinal=eof)
         return w_res
@@ -674,12 +674,12 @@
         if space.is_w(w_context, space.w_None):
             context = None
         else:
-            context = space.str_w(w_context)
+            context = space.text_w(w_context)
 
         if space.is_none(w_encoding):
             encoding = None
         else:
-            encoding = space.str_w(w_encoding)
+            encoding = space.text_w(w_encoding)
 
         xmlparser = XML_ExternalEntityParserCreate(
             self.itself, context, encoding)
@@ -812,8 +812,8 @@
 Return a new XML parser object."""
     if space.is_none(w_encoding):
         encoding = None
-    elif space.isinstance_w(w_encoding, space.w_str):
-        encoding = space.str_w(w_encoding)
+    elif space.isinstance_w(w_encoding, space.w_text):
+        encoding = space.text_w(w_encoding)
     else:
         raise oefmt(space.w_TypeError,
                     "ParserCreate() argument 1 must be string or None, not %T",
@@ -821,8 +821,8 @@
 
     if space.is_none(w_namespace_separator):
         namespace_separator = 0
-    elif space.isinstance_w(w_namespace_separator, space.w_str):
-        separator = space.str_w(w_namespace_separator)
+    elif space.isinstance_w(w_namespace_separator, space.w_text):
+        separator = space.text_w(w_namespace_separator)
         if len(separator) == 0:
             namespace_separator = 0
         elif len(separator) == 1:
diff --git a/pypy/module/sys/interp_encoding.py 
b/pypy/module/sys/interp_encoding.py
--- a/pypy/module/sys/interp_encoding.py
+++ b/pypy/module/sys/interp_encoding.py
@@ -10,7 +10,7 @@
 def setdefaultencoding(space, w_encoding):
     """Set the current default string encoding used by the Unicode
 implementation."""
-    encoding = space.str_w(w_encoding)
+    encoding = space.text_w(w_encoding)
     mod = space.getbuiltinmodule("_codecs")
     w_lookup = space.getattr(mod, space.newtext("lookup"))
     # check whether the encoding is there
diff --git a/pypy/module/termios/interp_termios.py 
b/pypy/module/termios/interp_termios.py
--- a/pypy/module/termios/interp_termios.py
+++ b/pypy/module/termios/interp_termios.py
@@ -28,11 +28,9 @@
     cc = []
     for w_c in space.unpackiterable(w_cc):
         if space.isinstance_w(w_c, space.w_int):
-            ch = space.call_function(space.getattr(w_builtin,
-                                          space.newtext('chr')), w_c)
-            cc.append(space.str_w(ch))
-        else:
-            cc.append(space.str_w(w_c))
+            w_c = space.call_function(space.getattr(w_builtin,
+                                      space.newtext('chr')), w_c)
+        cc.append(space.bytes_w(w_c))
     tup = (space.int_w(w_iflag), space.int_w(w_oflag),
            space.int_w(w_cflag), space.int_w(w_lflag),
            space.int_w(w_ispeed), space.int_w(w_ospeed), cc)
diff --git a/pypy/module/zipimport/interp_zipimport.py 
b/pypy/module/zipimport/interp_zipimport.py
--- a/pypy/module/zipimport/interp_zipimport.py
+++ b/pypy/module/zipimport/interp_zipimport.py
@@ -293,7 +293,7 @@
         for compiled, _, ext in ENUMERATE_EXTS:
             if self.have_modulefile(space, filename + ext):
                 w_source = self.get_data(space, filename + ext)
-                source = space.str_w(w_source)
+                source = space.bytes_w(w_source)
                 if compiled:
                     magic = importing._get_long(source[:4])
                     timestamp = importing._get_long(source[4:8])
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -93,7 +93,7 @@
 
 class Object(object):
     def descr__getattribute__(space, w_obj, w_name):
-        name = space.str_w(w_name)
+        name = space.text_w(w_name)
         w_descr = space.lookup(w_obj, name)
         if w_descr is not None:
             if space.is_data_descr(w_descr):
@@ -112,7 +112,7 @@
         raiseattrerror(space, w_obj, name)
 
     def descr__setattr__(space, w_obj, w_name, w_value):
-        name = space.str_w(w_name)
+        name = space.text_w(w_name)
         w_descr = space.lookup(w_obj, name)
         if w_descr is not None:
             if space.is_data_descr(w_descr):
@@ -123,7 +123,7 @@
         raiseattrerror(space, w_obj, name, w_descr)
 
     def descr__delattr__(space, w_obj, w_name):
-        name = space.str_w(w_name)
+        name = space.text_w(w_name)
         w_descr = space.lookup(w_obj, name)
         if w_descr is not None:
             if space.is_data_descr(w_descr):
@@ -860,7 +860,7 @@
             if space.isinstance_w(w_result, space.w_str):
                 return w_result
             try:
-                result = space.str_w(w_result)
+                result = space.str_w(w_result) # YYY
             except OperationError, e:
                 if not e.match(space, space.w_TypeError):
                     raise
diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -146,7 +146,7 @@
         return False
 
     def _join_check_item(self, space, w_obj):
-        if (space.isinstance_w(w_obj, space.w_str) or
+        if (space.isinstance_w(w_obj, space.w_bytes) or
             space.isinstance_w(w_obj, space.w_bytearray)):
             return 0
         return 1
@@ -175,7 +175,7 @@
 
     @staticmethod
     def descr_fromhex(space, w_bytearraytype, w_hexstring):
-        hexstring = space.str_w(w_hexstring)
+        hexstring = space.text_w(w_hexstring)
         data = _hexstring_to_array(space, hexstring)
         # in CPython bytearray.fromhex is a staticmethod, so
         # we ignore w_type and always return a bytearray
@@ -484,8 +484,8 @@
 
 
 def getbytevalue(space, w_value):
-    if space.isinstance_w(w_value, space.w_str):
-        string = space.str_w(w_value)
+    if space.isinstance_w(w_value, space.w_bytes):
+        string = space.bytes_w(w_value)
         if len(string) != 1:
             raise oefmt(space.w_ValueError, "string must be of size 1")
         return string[0]
diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py
--- a/pypy/objspace/std/callmethod.py
+++ b/pypy/objspace/std/callmethod.py
@@ -44,7 +44,7 @@
 
     w_type = space.type(w_obj)
     if w_type.has_object_getattribute():
-        name = space.str_w(w_name)
+        name = space.text_w(w_name)
         # bit of a mess to use these internal functions, but it allows the
         # mapdict caching below to work without an additional lookup
         version_tag = w_type.version_tag()
@@ -106,7 +106,7 @@
                 break
             w_value = f.popvalue()
             w_key = f.popvalue()
-            key = f.space.str_w(w_key)
+            key = f.space.text_w(w_key)
             keywords[n_kwargs] = key
             keywords_w[n_kwargs] = w_value
 
diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -56,8 +56,8 @@
 
     def setitem(self, w_dict, w_key, w_value):
         space = self.space
-        if space.is_w(space.type(w_key), space.w_str):
-            self.setitem_str(w_dict, space.str_w(w_key), w_value)
+        if space.is_w(space.type(w_key), space.w_text):
+            self.setitem_str(w_dict, space.text_w(w_key), w_value)
         else:
             self.switch_to_object_strategy(w_dict)
             w_dict.setitem(w_key, w_value)
@@ -75,8 +75,8 @@
 
     def setdefault(self, w_dict, w_key, w_default):
         space = self.space
-        if space.is_w(space.type(w_key), space.w_str):
-            key = space.str_w(w_key)
+        if space.is_w(space.type(w_key), space.w_text):
+            key = space.text_w(w_key)
             cell = self.getdictvalue_no_unwrapping(w_dict, key)
             w_result = unwrap_cell(self.space, cell)
             if w_result is not None:
@@ -90,8 +90,8 @@
     def delitem(self, w_dict, w_key):
         space = self.space
         w_key_type = space.type(w_key)
-        if space.is_w(w_key_type, space.w_str):
-            key = space.str_w(w_key)
+        if space.is_w(w_key_type, space.w_text):
+            key = space.text_w(w_key)
             dict_w = self.unerase(w_dict.dstorage)
             try:
                 del dict_w[key]
@@ -111,8 +111,8 @@
     def getitem(self, w_dict, w_key):
         space = self.space
         w_lookup_type = space.type(w_key)
-        if space.is_w(w_lookup_type, space.w_str):
-            return self.getitem_str(w_dict, space.str_w(w_key))
+        if space.is_w(w_lookup_type, space.w_text):
+            return self.getitem_str(w_dict, space.text_w(w_key))
 
         elif _never_equal_to_string(space, w_lookup_type):
             return None
diff --git a/pypy/objspace/std/classdict.py b/pypy/objspace/std/classdict.py
--- a/pypy/objspace/std/classdict.py
+++ b/pypy/objspace/std/classdict.py
@@ -20,7 +20,7 @@
         w_lookup_type = space.type(w_key)
         if (space.is_w(w_lookup_type, space.w_str) or  # Most common path first
             space.abstract_issubclass_w(w_lookup_type, space.w_str)):
-            return self.getitem_str(w_dict, space.str_w(w_key))
+            return self.getitem_str(w_dict, space.text_w(w_key))
         elif space.abstract_issubclass_w(w_lookup_type, space.w_unicode):
             try:
                 w_key = space.str(w_key)
@@ -29,7 +29,7 @@
                     raise
                 # non-ascii unicode is never equal to a byte string
                 return None
-            return self.getitem_str(w_dict, space.str_w(w_key))
+            return self.getitem_str(w_dict, space.text_w(w_key))
         else:
             return None
 
@@ -39,7 +39,7 @@
     def setitem(self, w_dict, w_key, w_value):
         space = self.space
         if space.is_w(space.type(w_key), space.w_str):
-            self.setitem_str(w_dict, self.space.str_w(w_key), w_value)
+            self.setitem_str(w_dict, self.space.text_w(w_key), w_value)
         else:
             raise oefmt(space.w_TypeError,
                         "cannot add non-string keys to dict of a type")
@@ -71,7 +71,7 @@
         space = self.space
         w_key_type = space.type(w_key)
         if space.is_w(w_key_type, space.w_str):
-            key = self.space.str_w(w_key)
+            key = self.space.text_w(w_key)
             if not self.unerase(w_dict.dstorage).deldictvalue(space, key):
                 raise KeyError
         else:
diff --git a/pypy/objspace/std/dictmultiobject.py 
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -1418,7 +1418,7 @@
         w_seq = space.call_function(space.w_list, self)
         w_repr = space.repr(w_seq)
         return space.newtext("%s(%s)" % (space.type(self).getname(space),
-                                         space.str_w(w_repr)))
+                                         space.text_w(w_repr)))
 
     def descr_len(self, space):
         return space.len(self.w_dict)
diff --git a/pypy/objspace/std/dictproxyobject.py 
b/pypy/objspace/std/dictproxyobject.py
--- a/pypy/objspace/std/dictproxyobject.py
+++ b/pypy/objspace/std/dictproxyobject.py
@@ -39,7 +39,7 @@
 
     def descr_repr(self, space):
         return space.newtext("dict_proxy(%s)" %
-                                (space.str_w(space.repr(self.w_mapping)),))
+                                (space.text_w(space.repr(self.w_mapping)),))
 
     @unwrap_spec(w_default=WrappedDefault(None))
     def get_w(self, space, w_key, w_default):
diff --git a/pypy/objspace/std/kwargsdict.py b/pypy/objspace/std/kwargsdict.py
--- a/pypy/objspace/std/kwargsdict.py
+++ b/pypy/objspace/std/kwargsdict.py
@@ -31,7 +31,7 @@
         return _wrapkey(self.space, key)
 
     def unwrap(self, wrapped):
-        return self.space.str_w(wrapped)
+        return self.space.text_w(wrapped)
 
     def get_empty_storage(self):
         d = ([], [])
diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py
--- a/pypy/objspace/std/longobject.py
+++ b/pypy/objspace/std/longobject.py
@@ -579,9 +579,9 @@
             else:
                 w_obj = space.int(w_obj)
             return newbigint(space, w_longtype, space.bigint_w(w_obj))
-        elif space.isinstance_w(w_value, space.w_str):
+        elif space.isinstance_w(w_value, space.w_bytes):
             return _string_to_w_long(space, w_longtype, w_value,
-                                     space.str_w(w_value))
+                                     space.bytes_w(w_value))
         elif space.isinstance_w(w_value, space.w_unicode):
             from pypy.objspace.std.unicodeobject import unicode_to_decimal_w
             return _string_to_w_long(space, w_longtype, w_value,
@@ -605,7 +605,7 @@
             s = unicode_to_decimal_w(space, w_value)
         else:
             try:
-                s = space.str_w(w_value)
+                s = space.bytes_w(w_value)
             except OperationError:
                 raise oefmt(space.w_TypeError,
                             "long() can't convert non-string with explicit "
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -739,7 +739,7 @@
         space = self.space
         w_lookup_type = space.type(w_key)
         if space.is_w(w_lookup_type, space.w_str):
-            return self.getitem_str(w_dict, space.str_w(w_key))
+            return self.getitem_str(w_dict, space.text_w(w_key))
         elif _never_equal_to_string(space, w_lookup_type):
             return None
         else:
@@ -758,7 +758,7 @@
     def setitem(self, w_dict, w_key, w_value):
         space = self.space
         if space.is_w(space.type(w_key), space.w_str):
-            self.setitem_str(w_dict, self.space.str_w(w_key), w_value)
+            self.setitem_str(w_dict, self.space.text_w(w_key), w_value)
         else:
             self.switch_to_object_strategy(w_dict)
             w_dict.setitem(w_key, w_value)
@@ -766,7 +766,7 @@
     def setdefault(self, w_dict, w_key, w_default):
         space = self.space
         if space.is_w(space.type(w_key), space.w_str):
-            key = space.str_w(w_key)
+            key = space.text_w(w_key)
             w_result = self.getitem_str(w_dict, key)
             if w_result is not None:
                 return w_result
@@ -781,7 +781,7 @@
         w_key_type = space.type(w_key)
         w_obj = self.unerase(w_dict.dstorage)
         if space.is_w(w_key_type, space.w_str):
-            key = self.space.str_w(w_key)
+            key = self.space.text_w(w_key)
             flag = w_obj.deldictvalue(space, key)
             if not flag:
                 raise KeyError
@@ -981,7 +981,7 @@
             return space._handle_getattribute(w_descr, w_obj, w_name)
         version_tag = w_type.version_tag()
         if version_tag is not None:
-            name = space.str_w(w_name)
+            name = space.text_w(w_name)
             # We need to care for obscure cases in which the w_descr is
             # a MutableCell, which may change without changing the version_tag
             _, w_descr = w_type._pure_lookup_where_with_method_cache(
diff --git a/pypy/objspace/std/objectobject.py 
b/pypy/objspace/std/objectobject.py
--- a/pypy/objspace/std/objectobject.py
+++ b/pypy/objspace/std/objectobject.py
@@ -161,7 +161,7 @@
         w_module = w_type.lookup("__module__")
         if w_module is not None:
             try:
-                modulename = space.str_w(w_module)
+                modulename = space.text_w(w_module)
             except OperationError as e:
                 if not e.match(space, space.w_TypeError):
                     raise
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -1248,7 +1248,7 @@
         return True
 
     def unwrap(self, w_item):
-        return self.space.str_w(w_item)
+        return self.space.bytes_w(w_item)
 
     def wrap(self, item):
         return self.space.newbytes(item)
diff --git a/pypy/objspace/std/sliceobject.py b/pypy/objspace/std/sliceobject.py
--- a/pypy/objspace/std/sliceobject.py
+++ b/pypy/objspace/std/sliceobject.py
@@ -106,9 +106,9 @@
 
     def descr_repr(self, space):
         return space.newtext("slice(%s, %s, %s)" % (
-            space.str_w(space.repr(self.w_start)),
-            space.str_w(space.repr(self.w_stop)),
-            space.str_w(space.repr(self.w_step))))
+            space.text_w(space.repr(self.w_start)),
+            space.text_w(space.repr(self.w_stop)),
+            space.text_w(space.repr(self.w_step))))
 
     def descr__reduce__(self, space):
         from pypy.objspace.std.sliceobject import W_SliceObject
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py 
b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -1094,11 +1094,13 @@
             return str
         return type(w_obj)
     w_str = str
+    w_text = str
 
     def str_w(self, string):
         assert isinstance(string, str)
         return string
     bytes_w = str_w
+    text_w = str_w
 
     def int_w(self, integer, allow_conversion=True):
         assert isinstance(integer, int)
diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py
--- a/pypy/objspace/std/tupleobject.py
+++ b/pypy/objspace/std/tupleobject.py
@@ -102,8 +102,8 @@
     def descr_repr(self, space):
         items = self.tolist()
         if len(items) == 1:
-            return space.newtext("(" + space.str_w(space.repr(items[0])) + 
",)")
-        tmp = ", ".join([space.str_w(space.repr(item)) for item in items])
+            return space.newtext("(" + space.text_w(space.repr(items[0])) + 
",)")
+        tmp = ", ".join([space.text_w(space.repr(item)) for item in items])
         return space.newtext("(" + tmp + ")")
 
     def descr_hash(self, space):
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -638,7 +638,7 @@
         if w_mod is None or not space.isinstance_w(w_mod, space.w_str):
             mod = None
         else:
-            mod = space.str_w(w_mod)
+            mod = space.text_w(w_mod)
         if not self.is_heaptype():
             kind = 'type'
         else:
@@ -649,7 +649,7 @@
             return space.newtext("<%s '%s'>" % (kind, self.name))
 
     def descr_getattribute(self, space, w_name):
-        name = space.str_w(w_name)
+        name = space.text_w(w_name)
         w_descr = space.lookup(self, name)
         if w_descr is not None:
             if space.is_data_descr(w_descr):
@@ -729,14 +729,14 @@
             return space.call_function(newfunc, w_winner, w_name, w_bases, 
w_dict)
         w_typetype = w_winner
 
-    name = space.str_w(w_name)
+    name = space.text_w(w_name)
     assert isinstance(name, str)
     if '\x00' in name:
         raise oefmt(space.w_ValueError, "type name must not contain null 
characters")
     dict_w = {}
     dictkeys_w = space.listview(w_dict)
     for w_key in dictkeys_w:
-        key = space.str_w(w_key)
+        key = space.text_w(w_key)
         dict_w[key] = space.getitem(w_dict, w_key)
     w_type = space.allocate_instance(W_TypeObject, w_typetype)
     W_TypeObject.__init__(w_type, space, name, bases_w or [space.w_object],
@@ -779,7 +779,7 @@
         raise oefmt(space.w_TypeError,
                     "can only assign string to %N.__name__, not '%T'",
                     w_type, w_value)
-    name = space.str_w(w_value)
+    name = space.text_w(w_value)
     if '\x00' in name:
         raise oefmt(space.w_ValueError, "type name must not contain null 
characters")
     w_type.name = name
@@ -1055,7 +1055,7 @@
         else:
             slot_names_w = space.unpackiterable(w_slots)
         for w_slot_name in slot_names_w:
-            slot_name = space.str_w(w_slot_name)
+            slot_name = space.text_w(w_slot_name)
             if slot_name == '__dict__':
                 if wantdict or w_bestbase.hasdict:
                     raise oefmt(space.w_TypeError,
@@ -1106,7 +1106,7 @@
     slot_name = mangle(slot_name, w_self.name)
     if slot_name not in w_self.dict_w:
         # Force interning of slot names.
-        slot_name = space.str_w(space.new_interned_str(slot_name))
+        slot_name = space.text_w(space.new_interned_str(slot_name))
         # in cpython it is ignored less, but we probably don't care
         member = Member(index_next_extra_slot, slot_name, w_self)
         w_self.dict_w[slot_name] = member
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to