[pypy-commit] pypy default: Replace space.realstr_w -> space.realtext_w and 'str_or_None' ->

arigo pypy.commits at gmail.com
Wed Feb 22 09:52:02 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r90297:5b74b06f962b
Date: 2017-02-22 15:11 +0100
http://bitbucket.org/pypy/pypy/changeset/5b74b06f962b/

Log:	Replace space.realstr_w -> space.realtext_w and 'str_or_None' ->
	'text_or_none'. Fix a few places that accepted "str_or_None" but
	where it was really meant "fsencode or None".

diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -420,7 +420,7 @@
         w_decorator_list = get_field(space, w_node, 'decorator_list', False)
         w_lineno = get_field(space, w_node, 'lineno', False)
         w_col_offset = get_field(space, w_node, 'col_offset', False)
-        _name = space.realstr_w(w_name)
+        _name = space.realtext_w(w_name)
         if _name is None:
             raise_required_value(space, w_node, 'name')
         _args = arguments.from_object(space, w_args)
@@ -497,7 +497,7 @@
         w_decorator_list = get_field(space, w_node, 'decorator_list', False)
         w_lineno = get_field(space, w_node, 'lineno', False)
         w_col_offset = get_field(space, w_node, 'col_offset', False)
-        _name = space.realstr_w(w_name)
+        _name = space.realtext_w(w_name)
         if _name is None:
             raise_required_value(space, w_node, 'name')
         bases_w = space.unpackiterable(w_bases)
@@ -1318,7 +1318,7 @@
         w_level = get_field(space, w_node, 'level', True)
         w_lineno = get_field(space, w_node, 'lineno', False)
         w_col_offset = get_field(space, w_node, 'col_offset', False)
-        _module = space.str_or_None_w(w_module)
+        _module = space.realtext_w(w_module) if not space.is_none(w_module) else space.w_None
         names_w = space.unpackiterable(w_names)
         _names = [alias.from_object(space, w_item) for w_item in names_w]
         _level = space.int_w(w_level)
@@ -1413,7 +1413,7 @@
         w_lineno = get_field(space, w_node, 'lineno', False)
         w_col_offset = get_field(space, w_node, 'col_offset', False)
         names_w = space.unpackiterable(w_names)
-        _names = [space.realstr_w(w_item) for w_item in names_w]
+        _names = [space.realtext_w(w_item) for w_item in names_w]
         _lineno = space.int_w(w_lineno)
         _col_offset = space.int_w(w_col_offset)
         return Global(_names, _lineno, _col_offset)
@@ -2495,7 +2495,7 @@
         _value = expr.from_object(space, w_value)
         if _value is None:
             raise_required_value(space, w_node, 'value')
-        _attr = space.realstr_w(w_attr)
+        _attr = space.realtext_w(w_attr)
         if _attr is None:
             raise_required_value(space, w_node, 'attr')
         _ctx = expr_context.from_object(space, w_ctx)
@@ -2592,7 +2592,7 @@
         w_ctx = get_field(space, w_node, 'ctx', False)
         w_lineno = get_field(space, w_node, 'lineno', False)
         w_col_offset = get_field(space, w_node, 'col_offset', False)
-        _id = space.realstr_w(w_id)
+        _id = space.realtext_w(w_id)
         if _id is None:
             raise_required_value(space, w_node, 'id')
         _ctx = expr_context.from_object(space, w_ctx)
@@ -3415,8 +3415,8 @@
         w_defaults = get_field(space, w_node, 'defaults', False)
         args_w = space.unpackiterable(w_args)
         _args = [expr.from_object(space, w_item) for w_item in args_w]
-        _vararg = space.str_or_None_w(w_vararg)
-        _kwarg = space.str_or_None_w(w_kwarg)
+        _vararg = space.realtext_w(w_vararg) if not space.is_none(w_vararg) else space.w_None
+        _kwarg = space.realtext_w(w_kwarg) if not space.is_none(w_kwarg) else space.w_None
         defaults_w = space.unpackiterable(w_defaults)
         _defaults = [expr.from_object(space, w_item) for w_item in defaults_w]
         return arguments(_args, _vararg, _kwarg, _defaults)
@@ -3448,7 +3448,7 @@
     def from_object(space, w_node):
         w_arg = get_field(space, w_node, 'arg', False)
         w_value = get_field(space, w_node, 'value', False)
-        _arg = space.realstr_w(w_arg)
+        _arg = space.realtext_w(w_arg)
         if _arg is None:
             raise_required_value(space, w_node, 'arg')
         _value = expr.from_object(space, w_value)
@@ -3482,10 +3482,10 @@
     def from_object(space, w_node):
         w_name = get_field(space, w_node, 'name', False)
         w_asname = get_field(space, w_node, 'asname', True)
-        _name = space.realstr_w(w_name)
+        _name = space.realtext_w(w_name)
         if _name is None:
             raise_required_value(space, w_node, 'name')
-        _asname = space.str_or_None_w(w_asname)
+        _asname = space.realtext_w(w_asname) if not space.is_none(w_asname) else space.w_None
         return alias(_name, _asname)
 
 State.ast_type('alias', 'AST', ['name', 'asname'])
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -150,8 +150,9 @@
             return "check_string(space, %s)" % (value,)
         elif field.type in ("identifier",):
             if field.opt:
-                return "space.str_or_None_w(%s)" % (value,)
-            return "space.realstr_w(%s)" % (value,)
+                return ("space.realtext_w(%s) if not space.is_none(%s) "
+                        "else space.w_None" % (value, value))
+            return "space.realtext_w(%s)" % (value,)
         elif field.type in ("int",):
             return "space.int_w(%s)" % (value,)
         elif field.type in ("bool",):
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1604,9 +1604,9 @@
         else:
             return buf.as_str()
 
-    def str_or_None_w(self, w_obj):
-        # YYY rename
-        return None if self.is_none(w_obj) else self.bytes_w(w_obj)
+    def text_or_none_w(self, w_obj):
+        # return text_w(w_obj) or None
+        return None if self.is_none(w_obj) else self.text_w(w_obj)
 
     def bytes_w(self, w_obj):
         "Takes a bytes object and returns an unwrapped RPython bytestring."
@@ -1647,6 +1647,9 @@
                                      getfilesystemencoding(self))
         return self.bytes0_w(w_obj)
 
+    def fsencode_or_none_w(self, w_obj):
+        return None if self.is_none(w_obj) else self.fsencode_w(w_obj)
+
     def int_w(self, w_obj, allow_conversion=True):
         """
         Unwrap an app-level int object into an interpret-level int.
@@ -1681,9 +1684,9 @@
         """
         return w_obj.float_w(self, allow_conversion)
 
-    def realstr_w(self, w_obj):
-        # YYY rename
-        # Like bytes_w, but only works if w_obj is really of type 'str'.
+    def realtext_w(self, w_obj):
+        # Like bytes_w(), but only works if w_obj is really of type 'str'.
+        # On Python 3 this is the same as text_w().
         if not self.isinstance_w(w_obj, self.w_bytes):
             raise oefmt(self.w_TypeError, "argument must be a string")
         return self.bytes_w(w_obj)
@@ -1702,8 +1705,8 @@
         return rstring.assert_str0(result)
 
     def realunicode_w(self, w_obj):
-        # Like unicode_w, but only works if w_obj is really of type
-        # 'unicode'.
+        # Like unicode_w(), but only works if w_obj is really of type
+        # 'unicode'.  On Python 3 this is the same as unicode_w().
         if not self.isinstance_w(w_obj, self.w_unicode):
             raise oefmt(self.w_TypeError, "argument must be a unicode")
         return self.unicode_w(w_obj)
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -145,7 +145,7 @@
     def visit_bufferstr(self, el, app_sig):
         self.checked_space_method(el, app_sig)
 
-    def visit_str_or_None(self, el, app_sig):
+    def visit_text_or_none(self, el, app_sig):
         self.checked_space_method(el, app_sig)
 
     def visit_bytes(self, el, app_sig):
@@ -163,6 +163,9 @@
     def visit_fsencode(self, el, app_sig):
         self.checked_space_method(el, app_sig)
 
+    def visit_fsencode_or_none(self, el, app_sig):
+        self.checked_space_method(el, app_sig)
+
     def visit_nonnegint(self, el, app_sig):
         self.checked_space_method(el, app_sig)
 
@@ -286,8 +289,8 @@
     def visit_bufferstr(self, typ):
         self.run_args.append("space.bufferstr_w(%s)" % (self.scopenext(),))
 
-    def visit_str_or_None(self, typ):
-        self.run_args.append("space.str_or_None_w(%s)" % (self.scopenext(),))
+    def visit_text_or_none(self, typ):
+        self.run_args.append("space.text_or_none_w(%s)" % (self.scopenext(),))
 
     def visit_bytes(self, typ):
         self.run_args.append("space.bytes_w(%s)" % (self.scopenext(),))
@@ -304,6 +307,9 @@
     def visit_fsencode(self, typ):
         self.run_args.append("space.fsencode_w(%s)" % (self.scopenext(),))
 
+    def visit_fsencode_or_none(self, typ):
+        self.run_args.append("space.fsencode_or_none_w(%s)" % (self.scopenext(),))
+
     def visit_nonnegint(self, typ):
         self.run_args.append("space.gateway_nonnegint_w(%s)" % (
             self.scopenext(),))
@@ -448,8 +454,8 @@
     def visit_bufferstr(self, typ):
         self.unwrap.append("space.bufferstr_w(%s)" % (self.nextarg(),))
 
-    def visit_str_or_None(self, typ):
-        self.unwrap.append("space.str_or_None_w(%s)" % (self.nextarg(),))
+    def visit_text_or_none(self, typ):
+        self.unwrap.append("space.text_or_none_w(%s)" % (self.nextarg(),))
 
     def visit_bytes(self, typ):
         self.unwrap.append("space.bytes_w(%s)" % (self.nextarg(),))
@@ -466,6 +472,9 @@
     def visit_fsencode(self, typ):
         self.unwrap.append("space.fsencode_w(%s)" % (self.nextarg(),))
 
+    def visit_fsencode_or_none(self, typ):
+        self.unwrap.append("space.fsencode_or_none_w(%s)" % (self.nextarg(),))
+
     def visit_nonnegint(self, typ):
         self.unwrap.append("space.gateway_nonnegint_w(%s)" % (self.nextarg(),))
 
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -25,7 +25,7 @@
 
 # helper
 
-def unpack_text_tuple(space,w_str_tuple):
+def unpack_text_tuple(space, w_str_tuple):
     return [space.text_w(w_el) for w_el in space.unpackiterable(w_str_tuple)]
 
 
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
@@ -377,7 +377,7 @@
             return space.wrap(s0+s1)
         app_g3_ss = gateway.interp2app_temp(g3_ss,
                                          unwrap_spec=[gateway.ObjSpace,
-                                                      'text', 'str_or_None'])
+                                                      'text', 'text_or_none'])
         w_app_g3_ss = space.wrap(app_g3_ss)
         assert self.space.eq_w(
             space.call(w_app_g3_ss,
diff --git a/pypy/module/_cffi_backend/ffi_obj.py b/pypy/module/_cffi_backend/ffi_obj.py
--- a/pypy/module/_cffi_backend/ffi_obj.py
+++ b/pypy/module/_cffi_backend/ffi_obj.py
@@ -572,7 +572,7 @@
         return self.ffi_type(w_arg, ACCEPT_STRING | ACCEPT_CDATA)
 
 
-    @unwrap_spec(filename="str_or_None", flags=int)
+    @unwrap_spec(filename="fsencode_or_none", flags=int)
     def descr_dlopen(self, filename, flags=0):
         """\
 Load and return a dynamic library identified by 'name'.  The standard
diff --git a/pypy/module/_cffi_backend/libraryobj.py b/pypy/module/_cffi_backend/libraryobj.py
--- a/pypy/module/_cffi_backend/libraryobj.py
+++ b/pypy/module/_cffi_backend/libraryobj.py
@@ -91,7 +91,7 @@
 W_Library.typedef.acceptable_as_base_class = False
 
 
- at unwrap_spec(filename="str_or_None", flags=int)
+ at unwrap_spec(filename="fsencode_or_none", flags=int)
 def load_library(space, filename, flags=0):
     lib = W_Library(space, filename, flags)
     return lib
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
@@ -314,12 +314,12 @@
     w_res = space.call_function(w_encoder, w_obj, space.newtext(errors))
     return space.getitem(w_res, space.newint(0))
 
- at unwrap_spec(errors='str_or_None')
+ at unwrap_spec(errors='text_or_none')
 def readbuffer_encode(space, w_data, errors='strict'):
     s = space.getarg_w('s#', w_data)
     return space.newtuple([space.newbytes(s), space.newint(len(s))])
 
- at unwrap_spec(errors='str_or_None')
+ at unwrap_spec(errors='text_or_none')
 def charbuffer_encode(space, w_data, errors='strict'):
     s = space.getarg_w('t#', w_data)
     return space.newtuple([space.newbytes(s), space.newint(len(s))])
@@ -373,7 +373,7 @@
 def make_encoder_wrapper(name):
     rname = "unicode_encode_%s" % (name.replace("_encode", ""), )
     assert hasattr(runicode, rname)
-    @unwrap_spec(uni=unicode, errors='str_or_None')
+    @unwrap_spec(uni=unicode, errors='text_or_none')
     def wrap_encoder(space, uni, errors="strict"):
         if errors is None:
             errors = 'strict'
@@ -387,7 +387,7 @@
 def make_decoder_wrapper(name):
     rname = "str_decode_%s" % (name.replace("_decode", ""), )
     assert hasattr(runicode, rname)
-    @unwrap_spec(string='bufferstr', errors='str_or_None',
+    @unwrap_spec(string='bufferstr', errors='text_or_none',
                  w_final=WrappedDefault(False))
     def wrap_decoder(space, string, errors="strict", w_final=None):
         if errors is None:
@@ -437,7 +437,7 @@
 
 # utf-8 functions are not regular, because we have to pass
 # "allow_surrogates=True"
- at unwrap_spec(uni=unicode, errors='str_or_None')
+ at unwrap_spec(uni=unicode, errors='text_or_none')
 def utf_8_encode(space, uni, errors="strict"):
     if errors is None:
         errors = 'strict'
@@ -450,7 +450,7 @@
         allow_surrogates=True)
     return space.newtuple([space.newbytes(result), space.newint(len(uni))])
 
- at unwrap_spec(string='bufferstr', errors='str_or_None',
+ at unwrap_spec(string='bufferstr', errors='text_or_none',
              w_final = WrappedDefault(False))
 def utf_8_decode(space, string, errors="strict", w_final=None):
     if errors is None:
@@ -466,7 +466,7 @@
         allow_surrogates=True)
     return space.newtuple([space.newunicode(result), space.newint(consumed)])
 
- at unwrap_spec(data='bufferstr', errors='str_or_None', byteorder=int,
+ at unwrap_spec(data='bufferstr', errors='text_or_none', byteorder=int,
              w_final=WrappedDefault(False))
 def utf_16_ex_decode(space, data, errors='strict', byteorder=0, w_final=None):
     if errors is None:
@@ -487,7 +487,7 @@
     return space.newtuple([space.newunicode(res), space.newint(consumed),
                            space.newint(byteorder)])
 
- at unwrap_spec(data='bufferstr', errors='str_or_None', byteorder=int,
+ at unwrap_spec(data='bufferstr', errors='text_or_none', byteorder=int,
              w_final=WrappedDefault(False))
 def utf_32_ex_decode(space, data, errors='strict', byteorder=0, w_final=None):
     final = space.is_true(w_final)
@@ -585,7 +585,7 @@
             "character mapping must return integer, None or str")
 
 
- at unwrap_spec(string='bufferstr', errors='str_or_None')
+ at unwrap_spec(string='bufferstr', errors='text_or_none')
 def charmap_decode(space, string, errors="strict", w_mapping=None):
     if errors is None:
         errors = 'strict'
@@ -604,7 +604,7 @@
         final, state.decode_error_handler, mapping)
     return space.newtuple([space.newunicode(result), space.newint(consumed)])
 
- at unwrap_spec(uni=unicode, errors='str_or_None')
+ at unwrap_spec(uni=unicode, errors='text_or_none')
 def charmap_encode(space, uni, errors="strict", w_mapping=None):
     if errors is None:
         errors = 'strict'
@@ -647,7 +647,7 @@
             return -1
         return space.int_w(w_code)
 
- at unwrap_spec(string='bufferstr', errors='str_or_None',
+ at unwrap_spec(string='bufferstr', errors='text_or_none',
              w_final=WrappedDefault(False))
 def unicode_escape_decode(space, string, errors="strict", w_final=None):
     if errors is None:
@@ -667,7 +667,7 @@
 # ____________________________________________________________
 # Unicode-internal
 
- at unwrap_spec(errors='str_or_None')
+ at unwrap_spec(errors='text_or_none')
 def unicode_internal_decode(space, w_string, errors="strict"):
     if errors is None:
         errors = 'strict'
@@ -691,7 +691,7 @@
 # support for the "string escape" codec
 # This is a bytes-to bytes transformation
 
- at unwrap_spec(data='bytes', errors='str_or_None')
+ at unwrap_spec(data='bytes', errors='text_or_none')
 def escape_encode(space, data, errors='strict'):
     from pypy.objspace.std.bytesobject import string_escape_encode
     result = string_escape_encode(data, quote="'")
@@ -701,7 +701,7 @@
     w_result = space.newbytes(result[start:end])
     return space.newtuple([w_result, space.newint(len(data))])
 
- at unwrap_spec(data='bytes', errors='str_or_None')
+ at unwrap_spec(data='bytes', errors='text_or_none')
 def escape_decode(space, data, errors='strict'):
     from pypy.interpreter.pyparser.parsestring import PyString_DecodeEscape
     result = PyString_DecodeEscape(space, data, errors, None)
diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py
--- a/pypy/module/_file/interp_file.py
+++ b/pypy/module/_file/interp_file.py
@@ -666,7 +666,7 @@
     return False
 
 
- at unwrap_spec(w_file=W_File, encoding="str_or_None", errors="str_or_None")
+ at unwrap_spec(w_file=W_File, encoding="text_or_none", errors="text_or_none")
 def set_file_encoding(space, w_file, encoding=None, errors=None):
     w_file.encoding = encoding
     w_file.errors = errors
diff --git a/pypy/module/_io/interp_io.py b/pypy/module/_io/interp_io.py
--- a/pypy/module/_io/interp_io.py
+++ b/pypy/module/_io/interp_io.py
@@ -41,8 +41,8 @@
 DEFAULT_BUFFER_SIZE = 8 * 1024
 
 @unwrap_spec(mode='text', buffering=int,
-             encoding="str_or_None", errors="str_or_None",
-             newline="str_or_None", closefd=bool)
+             encoding="text_or_none", errors="text_or_none",
+             newline="text_or_none", closefd=bool)
 def open(space, w_file, mode="r", buffering=-1, encoding=None, errors=None,
     newline=None, closefd=True):
     from pypy.module._io.interp_bufferedio import (W_BufferedRandom,
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -359,7 +359,7 @@
                                               # of the stream
         self.snapshot = None
 
-    @unwrap_spec(encoding="str_or_None", line_buffering=int)
+    @unwrap_spec(encoding="text_or_none", line_buffering=int)
     def descr_init(self, space, w_buffer, encoding=None,
                    w_errors=None, w_newline=None, line_buffering=0):
         self.state = STATE_ZERO
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
@@ -68,7 +68,7 @@
         return space.newunicode(output)
 
 
- at unwrap_spec(errors="str_or_None")
+ at unwrap_spec(errors="text_or_none")
 def mbidecoder_new(space, w_subtype, errors=None):
     r = space.allocate_instance(MultibyteIncrementalDecoder, w_subtype)
     r.__init__(space, errors)
@@ -116,7 +116,7 @@
         return space.newbytes(output)
 
 
- at unwrap_spec(errors="str_or_None")
+ at unwrap_spec(errors="text_or_none")
 def mbiencoder_new(space, w_subtype, errors=None):
     r = space.allocate_instance(MultibyteIncrementalEncoder, w_subtype)
     r.__init__(space, errors)
diff --git a/pypy/module/_multibytecodec/interp_multibytecodec.py b/pypy/module/_multibytecodec/interp_multibytecodec.py
--- a/pypy/module/_multibytecodec/interp_multibytecodec.py
+++ b/pypy/module/_multibytecodec/interp_multibytecodec.py
@@ -11,7 +11,7 @@
         self.name = name
         self.codec = codec
 
-    @unwrap_spec(input='bytes', errors="str_or_None")
+    @unwrap_spec(input='bytes', errors="text_or_none")
     def decode(self, space, input, errors=None):
         if errors is None:
             errors = 'strict'
@@ -27,7 +27,7 @@
         return space.newtuple([space.newunicode(output),
                                space.newint(len(input))])
 
-    @unwrap_spec(input=unicode, errors="str_or_None")
+    @unwrap_spec(input=unicode, errors="text_or_none")
     def encode(self, space, input, errors=None):
         if errors is None:
             errors = 'strict'
diff --git a/pypy/module/_rawffi/alt/interp_funcptr.py b/pypy/module/_rawffi/alt/interp_funcptr.py
--- a/pypy/module/_rawffi/alt/interp_funcptr.py
+++ b/pypy/module/_rawffi/alt/interp_funcptr.py
@@ -344,7 +344,7 @@
     def getidentifier(self, space):
         return space.newint(self.cdll.getidentifier())
 
- at unwrap_spec(name='str_or_None', mode=int)
+ at unwrap_spec(name='fsencode_or_none', mode=int)
 def descr_new_cdll(space, w_type, name, mode=-1):
     return W_CDLL(space, name, mode)
 
@@ -363,7 +363,7 @@
         W_CDLL.__init__(self, space, name, mode)
         self.flags = libffi.FUNCFLAG_STDCALL
 
- at unwrap_spec(name='str_or_None', mode=int)
+ at unwrap_spec(name='fsencode_or_none', mode=int)
 def descr_new_windll(space, w_type, name, mode=-1):
     return W_WinDLL(space, name, mode)
 
diff --git a/pypy/module/_rawffi/interp_rawffi.py b/pypy/module/_rawffi/interp_rawffi.py
--- a/pypy/module/_rawffi/interp_rawffi.py
+++ b/pypy/module/_rawffi/interp_rawffi.py
@@ -235,7 +235,7 @@
     except OSError as e:
         raise wrap_oserror(space, e)
 
- at unwrap_spec(name='str_or_None')
+ at unwrap_spec(name='fsencode_or_none')
 def descr_new_cdll(space, w_type, name):
     cdll = open_cdll(space, name)
     return W_CDLL(space, name, cdll)
diff --git a/pypy/module/_winreg/interp_winreg.py b/pypy/module/_winreg/interp_winreg.py
--- a/pypy/module/_winreg/interp_winreg.py
+++ b/pypy/module/_winreg/interp_winreg.py
@@ -689,7 +689,7 @@
 
 The return value is the handle of the opened key.
 If the function fails, an EnvironmentError exception is raised."""
-    machine = space.str_or_None_w(w_machine)
+    machine = space.text_or_none_w(w_machine)
     hkey = hkey_w(w_hkey, space)
     with lltype.scoped_alloc(rwinreg.PHKEY.TO, 1) as rethkey:
         ret = rwinreg.RegConnectRegistry(machine, hkey, rethkey)
diff --git a/pypy/module/cpyext/memoryobject.py b/pypy/module/cpyext/memoryobject.py
--- a/pypy/module/cpyext/memoryobject.py
+++ b/pypy/module/cpyext/memoryobject.py
@@ -119,7 +119,7 @@
     try:
         view.c_buf = rffi.cast(rffi.VOIDP, buf.get_raw_address())
     except ValueError:
-        if not space.isinstance_w(w_obj, space.w_str):
+        if not space.isinstance_w(w_obj, space.w_bytes):
             # XXX Python 3?
             raise BufferError("could not create buffer from object")
         view.c_buf = rffi.cast(rffi.VOIDP, rffi.str2charp(space.bytes_w(w_obj), track_allocation=False))
diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -313,8 +313,8 @@
 
             return space.wrap(pydname)
 
-        @unwrap_spec(name='text', init='str_or_None', body='text',
-                     filename='str_or_None', PY_SSIZE_T_CLEAN=bool)
+        @unwrap_spec(name='text', init='text_or_none', body='text',
+                     filename='fsencode_or_none', PY_SSIZE_T_CLEAN=bool)
         def import_module(space, name, init=None, body='',
                           filename=None, w_include_dirs=None,
                           PY_SSIZE_T_CLEAN=False):
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
@@ -288,7 +288,7 @@
         space.realunicode_w(w_object)
         space.int_w(w_start)
         space.int_w(w_end)
-        space.realstr_w(w_reason)
+        space.realtext_w(w_reason)
         # assign attributes
         self.w_object = w_object
         self.w_start = w_start
@@ -628,11 +628,11 @@
 
     def descr_init(self, space, w_encoding, w_object, w_start, w_end, w_reason):
         # typechecking
-        space.realstr_w(w_encoding)
-        space.realstr_w(w_object)
+        space.realtext_w(w_encoding)
+        space.realtext_w(w_object)
         space.int_w(w_start)
         space.int_w(w_end)
-        space.realstr_w(w_reason)
+        space.realtext_w(w_reason)
         # assign attributes
         self.w_encoding = w_encoding
         self.w_object = w_object
@@ -718,11 +718,11 @@
 
     def descr_init(self, space, w_encoding, w_object, w_start, w_end, w_reason):
         # typechecking
-        space.realstr_w(w_encoding)
+        space.realtext_w(w_encoding)
         space.realunicode_w(w_object)
         space.int_w(w_start)
         space.int_w(w_end)
-        space.realstr_w(w_reason)
+        space.realtext_w(w_reason)
         # assign attributes
         self.w_encoding = w_encoding
         self.w_object = w_object
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
@@ -364,7 +364,7 @@
         length = space.len_w(w_fromlist)
         for i in range(length):
             w_name = space.getitem(w_fromlist, space.newint(i))
-            if not space.isinstance_w(w_name, space.w_str):
+            if not space.isinstance_w(w_name, space.w_text):
                 raise oefmt(space.w_TypeError,
                     "'fromlist' items must be str, not %T", w_name)
         if w_path is not None:
diff --git a/pypy/module/mmap/interp_mmap.py b/pypy/module/mmap/interp_mmap.py
--- a/pypy/module/mmap/interp_mmap.py
+++ b/pypy/module/mmap/interp_mmap.py
@@ -183,7 +183,7 @@
 
     def descr_setitem(self, w_index, w_value):
         space = self.space
-        value = space.realstr_w(w_value)
+        value = space.realtext_w(w_value)
         self.check_valid()
 
         self.check_writeable()
@@ -238,7 +238,7 @@
         if not space.isinstance_w(w_item, space.w_bytes):
             raise oefmt(space.w_IndexError,
                         "mmap slice assignment must be a string")
-        value = space.realstr_w(w_item)
+        value = space.realtext_w(w_item)
         if len(value) != (j - i):
             raise oefmt(space.w_IndexError,
                         "mmap slice assignment is wrong size")
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
@@ -181,7 +181,7 @@
         # we ignore w_type and always return a bytearray
         return new_bytearray(space, space.w_bytearray, data)
 
-    @unwrap_spec(encoding='str_or_None', errors='str_or_None')
+    @unwrap_spec(encoding='text_or_none', errors='text_or_none')
     def descr_init(self, space, w_source=None, encoding=None, errors=None):
         if w_source is None:
             w_source = space.newbytes('')


More information about the pypy-commit mailing list