Author: Armin Rigo <ar...@tunes.org>
Branch: py3.5
Changeset: r90304:0deea03316b3
Date: 2017-02-22 16:14 +0100
http://bitbucket.org/pypy/pypy/changeset/0deea03316b3/

Log:    Rename 'space.wrap_fsdecoded' -> 'space.newfilename'

diff --git a/pypy/bin/pyinteractive.py b/pypy/bin/pyinteractive.py
--- a/pypy/bin/pyinteractive.py
+++ b/pypy/bin/pyinteractive.py
@@ -145,7 +145,7 @@
         command = args.pop(0)
     for arg in args:
         space.call_method(space.sys.get('argv'), 'append',
-                          space.wrap_fsdecoded(arg))
+                          space.newfilename(arg))
 
     # load the source of the program given as command-line argument
     if interactiveconfig.runcommand:
diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -71,8 +71,8 @@
                         rlocale.setlocale(rlocale.LC_CTYPE, '')
                     except rlocale.LocaleError:
                         pass
-                w_executable = space.wrap_fsdecoded(argv[0])
-                w_argv = space.newlist([space.wrap_fsdecoded(s)
+                w_executable = space.newfilename(argv[0])
+                w_argv = space.newlist([space.newfilename(s)
                                         for s in argv[1:]])
                 w_exitcode = space.call_function(w_entry_point, w_executable, 
w_argv)
                 exitcode = space.int_w(w_exitcode)
@@ -130,7 +130,7 @@
         try:
             # initialize sys.{path,executable,stdin,stdout,stderr}
             # (in unbuffered mode, to avoid troubles) and import site
-            space.appexec([w_path, space.wrap_fsdecoded(home), w_initstdio],
+            space.appexec([w_path, space.newfilename(home), w_initstdio],
             r"""(path, home, initstdio):
                 import sys
                 sys.path[:] = path
diff --git a/pypy/interpreter/astcompiler/misc.py 
b/pypy/interpreter/astcompiler/misc.py
--- a/pypy/interpreter/astcompiler/misc.py
+++ b/pypy/interpreter/astcompiler/misc.py
@@ -20,7 +20,7 @@
     If the user has set this warning to raise an error, a SyntaxError will be
     raised."""
     w_msg = space.newtext(msg)
-    w_filename = space.wrap_fsdecoded(fn)
+    w_filename = space.newfilename(fn)
     w_lineno = space.newint(lineno)
     w_offset = space.newint(offset)
     _emit_syntax_warning(space, w_msg, w_filename, w_lineno, w_offset)
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1725,10 +1725,6 @@
             w_obj = self.fsdecode(w_obj)
         return self.unicode0_w(w_obj)
 
-    # BACKCOMPAT  -- replace me with newfilename()
-    def wrap_fsdecoded(self, x):
-        return self.newfilename(x)
-
     def bool_w(self, w_obj):
         # Unwraps a bool, also accepting an int for compatibility.
         # For cases where you need to accept bools and ints and nothing
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -663,9 +663,9 @@
     w_filename = None
     w_filename2 = None
     if filename is not None:
-        w_filename = space.wrap_fsdecoded(filename)
+        w_filename = space.newfilename(filename)
         if filename2 is not None:
-            w_filename2 = space.wrap_fsdecoded(filename2)
+            w_filename2 = space.newfilename(filename2)
     return wrap_oserror2(space, e, w_filename,
                          exception_name=exception_name,
                          w_exception_class=w_exception_class,
diff --git a/pypy/interpreter/main.py b/pypy/interpreter/main.py
--- a/pypy/interpreter/main.py
+++ b/pypy/interpreter/main.py
@@ -43,7 +43,7 @@
         space.setitem(w_globals, space.newtext('__builtins__'), space.builtin)
         if filename is not None:
             space.setitem(w_globals, space.newtext('__file__'),
-                          space.wrap_fsdecoded(filename))
+                          space.newfilename(filename))
 
         retval = pycode.exec_code(space, w_globals, w_globals)
         if eval:
diff --git a/pypy/interpreter/pyparser/error.py 
b/pypy/interpreter/pyparser/error.py
--- a/pypy/interpreter/pyparser/error.py
+++ b/pypy/interpreter/pyparser/error.py
@@ -30,7 +30,7 @@
                                            'replace')
             w_text = space.newunicode(text)
         if self.filename is not None:
-            w_filename = space.wrap_fsdecoded(self.filename)
+            w_filename = space.newfilename(self.filename)
         return space.newtuple([space.newtext(self.msg),
                                space.newtuple([w_filename,
                                                space.newint(self.lineno),
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
@@ -120,7 +120,7 @@
         w_EnvironmentError = [EnvironmentError]
         def wrap(self, obj):
             return [obj]
-        newint = newtext = newunicode = wrap_fsdecoded = wrap
+        newint = newtext = newunicode = newfilename = wrap
         def call_function(self, exc, w_errno, w_msg, w_filename=None):
             return (exc, w_errno, w_msg, w_filename)
     space = FakeSpace()
diff --git a/pypy/interpreter/test/test_fsencode.py 
b/pypy/interpreter/test/test_fsencode.py
--- a/pypy/interpreter/test/test_fsencode.py
+++ b/pypy/interpreter/test/test_fsencode.py
@@ -77,7 +77,7 @@
             assert space.fsdecode_w(w_enc) == st
 
             assert space.fsencode_w(w_enc) == space.bytes_w(w_enc)
-            assert space.eq_w(space.wrap_fsdecoded(space.bytes_w(w_enc)), 
w_st2)
+            assert space.eq_w(space.newfilename(space.bytes_w(w_enc)), w_st2)
 
     def test_null_byte(self):
         space = self.space
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -615,7 +615,7 @@
     co_varnames = GetSetProperty(PyCode.fget_co_varnames),
     co_freevars = GetSetProperty(PyCode.fget_co_freevars),
     co_cellvars = GetSetProperty(PyCode.fget_co_cellvars),
-    co_filename = interp_attrproperty('co_filename', cls=PyCode, 
wrapfn="wrap_fsdecoded"),
+    co_filename = interp_attrproperty('co_filename', cls=PyCode, 
wrapfn="newfilename"),
     co_name = interp_attrproperty('co_name', cls=PyCode, wrapfn="newtext"),
     co_firstlineno = interp_attrproperty('co_firstlineno', cls=PyCode, 
wrapfn="newint"),
     co_lnotab = interp_attrproperty('co_lnotab', cls=PyCode, 
wrapfn="newbytes"),
diff --git a/pypy/module/_cffi_backend/cffi1_module.py 
b/pypy/module/_cffi_backend/cffi1_module.py
--- a/pypy/module/_cffi_backend/cffi1_module.py
+++ b/pypy/module/_cffi_backend/cffi1_module.py
@@ -42,7 +42,7 @@
     w_name = space.newtext(name)
     module = Module(space, w_name)
     if path is not None:
-        module.setdictvalue(space, '__file__', space.wrap_fsdecoded(path))
+        module.setdictvalue(space, '__file__', space.newfilename(path))
     module.setdictvalue(space, 'ffi', ffi)
     module.setdictvalue(space, 'lib', lib)
     w_modules_dict = space.sys.get('modules')
diff --git a/pypy/module/_socket/interp_socket.py 
b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -40,7 +40,7 @@
             # Linux abstract namespace
             return space.newbytes(path)
         else:
-            return space.wrap_fsdecoded(path)
+            return space.newfilename(path)
     elif rsocket.HAS_AF_NETLINK and isinstance(addr, rsocket.NETLINKAddress):
         return space.newtuple([space.newint(addr.get_pid()),
                                space.newint(addr.get_groups())])
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -1495,9 +1495,9 @@
             lltype.free(ll_libname, flavor='raw')
     except rdynload.DLOpenError as e:
         w_name = space.newunicode(name.decode('ascii'))
-        w_path = space.wrap_fsdecoded(path)
+        w_path = space.newfilename(path)
         raise raise_import_error(space,
-            space.wrap_fsdecoded(e.msg), w_name, w_path)
+            space.newfilename(e.msg), w_name, w_path)
     look_for = None
     #
     if space.config.objspace.usemodules._cffi_backend:
@@ -1528,9 +1528,9 @@
         else:
             look_for = also_look_for
     msg = u"function %s not found in library %s" % (
-        unicode(look_for), space.unicode_w(space.wrap_fsdecoded(path)))
+        unicode(look_for), space.unicode_w(space.newfilename(path)))
     w_name = space.newunicode(name.decode('ascii'))
-    w_path = space.wrap_fsdecoded(path)
+    w_path = space.newfilename(path)
     raise_import_error(space, space.newunicode(msg), w_name, w_path)
 
 
diff --git a/pypy/module/cpyext/import_.py b/pypy/module/cpyext/import_.py
--- a/pypy/module/cpyext/import_.py
+++ b/pypy/module/cpyext/import_.py
@@ -145,7 +145,7 @@
     else:
         pathname = code.co_filename
     w_mod = importing.add_module(space, w_name)
-    space.setattr(w_mod, space.newtext('__file__'), 
space.wrap_fsdecoded(pathname))
+    space.setattr(w_mod, space.newtext('__file__'), 
space.newfilename(pathname))
     cpathname = importing.make_compiled_pathname(pathname)
     importing.exec_code_module(space, w_mod, code, pathname, cpathname)
     return w_mod
diff --git a/pypy/module/cpyext/modsupport.py b/pypy/module/cpyext/modsupport.py
--- a/pypy/module/cpyext/modsupport.py
+++ b/pypy/module/cpyext/modsupport.py
@@ -47,7 +47,7 @@
     state.package_context = None, None
 
     if f_path is not None:
-        dict_w = {'__file__': space.wrap_fsdecoded(f_path)}
+        dict_w = {'__file__': space.newfilename(f_path)}
     else:
         dict_w = {}
     convert_method_defs(space, dict_w, methods, None, w_mod, modname)
diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py
--- a/pypy/module/cpyext/pyerrors.py
+++ b/pypy/module/cpyext/pyerrors.py
@@ -147,7 +147,7 @@
     # XXX Doesn't actually do anything with PyErr_CheckSignals.
     if llfilename:
         filename = rffi.charp2str(llfilename)
-        w_filename = space.wrap_fsdecoded(filename)
+        w_filename = space.newfilename(filename)
     else:
         w_filename = space.w_None
 
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
@@ -256,9 +256,9 @@
         if pathname is not None:
             w_pathname = get_sourcefile(space, pathname)
         else:
-            w_pathname = space.wrap_fsdecoded(code_w.co_filename)
+            w_pathname = space.newfilename(code_w.co_filename)
         if cpathname is not None:
-            w_cpathname = space.wrap_fsdecoded(cpathname)
+            w_cpathname = space.newfilename(cpathname)
         else:
             w_cpathname = space.w_None
         space.setitem(w_dict, space.newtext("__file__"), w_pathname)
@@ -329,7 +329,7 @@
     start = len(filename) - 4
     stop = len(filename) - 1
     if not 0 <= start <= stop or filename[start:stop].lower() != ".py":
-        return space.wrap_fsdecoded(filename)
+        return space.newfilename(filename)
     py = make_source_pathname(filename)
     if py is None:
         py = filename[:-1]
@@ -339,8 +339,8 @@
         pass
     else:
         if stat.S_ISREG(st.st_mode):
-            return space.wrap_fsdecoded(py)
-    return space.wrap_fsdecoded(filename)
+            return space.newfilename(py)
+    return space.newfilename(filename)
 
 def update_code_filenames(space, code_w, pathname, oldname=None):
     assert isinstance(code_w, PyCode)
diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -117,7 +117,7 @@
 
     if state is not None:    # 'None' for testing only
         lib_extensions = os.path.join(lib_pypy, '__extensions__')
-        state.w_lib_extensions = state.space.wrap_fsdecoded(lib_extensions)
+        state.w_lib_extensions = state.space.newfilename(lib_extensions)
         importlist.append(lib_extensions)
 
     importlist.append(lib_pypy)
@@ -149,12 +149,12 @@
 
 @unwrap_spec(executable='fsencode')
 def pypy_find_executable(space, executable):
-    return space.wrap_fsdecoded(find_executable(executable))
+    return space.newfilename(find_executable(executable))
 
 
 @unwrap_spec(filename='fsencode')
 def pypy_resolvedirof(space, filename):
-    return space.wrap_fsdecoded(resolvedirof(filename))
+    return space.newfilename(resolvedirof(filename))
 
 
 @unwrap_spec(executable='fsencode')
@@ -171,12 +171,12 @@
                 path, prefix = find_stdlib(get_state(space), dyn_path)
         if path is None:
             return space.w_None
-    w_prefix = space.wrap_fsdecoded(prefix)
+    w_prefix = space.newfilename(prefix)
     space.setitem(space.sys.w_dict, space.newtext('prefix'), w_prefix)
     space.setitem(space.sys.w_dict, space.newtext('exec_prefix'), w_prefix)
     space.setitem(space.sys.w_dict, space.newtext('base_prefix'), w_prefix)
     space.setitem(space.sys.w_dict, space.newtext('base_exec_prefix'), 
w_prefix)
-    return space.newlist([space.wrap_fsdecoded(p) for p in path])
+    return space.newlist([space.newfilename(p) for p in path])
 
 def pypy_initfsencoding(space):
     space.sys.filesystemencoding = _getfilesystemencoding(space)
diff --git a/pypy/module/sys/state.py b/pypy/module/sys/state.py
--- a/pypy/module/sys/state.py
+++ b/pypy/module/sys/state.py
@@ -22,7 +22,7 @@
         # Initialize the default path
         srcdir = os.path.dirname(pypydir)
         path = compute_stdlib_path(self, srcdir)
-        self.w_path = space.newlist([space.wrap_fsdecoded(p) for p in path])
+        self.w_path = space.newlist([space.newfilename(p) for p in path])
 
 def get(space):
     return space.fromcache(State)
@@ -31,4 +31,4 @@
     """NOT_RPYTHON
     (should be removed from interpleveldefs before translation)"""
     from rpython.tool.udir import udir
-    return space.wrap_fsdecoded(str(udir))
+    return space.newfilename(str(udir))
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
@@ -53,9 +53,9 @@
         try:
             w_zipimporter = self.cache[name]
         except KeyError:
-            raise OperationError(space.w_KeyError, space.wrap_fsdecoded(name))
+            raise OperationError(space.w_KeyError, space.newfilename(name))
         assert isinstance(w_zipimporter, W_ZipImporter)
-        w_fs = space.wrap_fsdecoded
+        w_fs = space.newfilename
         w_d = space.newdict()
         for key, info in w_zipimporter.zip_file.NameToInfo.iteritems():
             if ZIPSEP != os.path.sep:
@@ -67,7 +67,7 @@
         return w_d
 
     def keys(self, space):
-        return space.newlist([space.wrap_fsdecoded(s)
+        return space.newlist([space.newfilename(s)
                               for s in self.cache.keys()])
 
     def values(self, space):
@@ -76,7 +76,7 @@
         return space.newlist(values_w)
 
     def items(self, space):
-        w_fs = space.wrap_fsdecoded
+        w_fs = space.newfilename
         items_w = [space.newtuple([w_fs(key), self._getitem(space, key)])
                    for key in self.cache.keys()]
         return space.newlist(items_w)
@@ -128,8 +128,8 @@
 
     def getprefix(self, space):
         if ZIPSEP == os.path.sep:
-            return space.wrap_fsdecoded(self.prefix)
-        return space.wrap_fsdecoded(self.prefix.replace(ZIPSEP, os.path.sep))
+            return space.newfilename(self.prefix)
+        return space.newfilename(self.prefix.replace(ZIPSEP, os.path.sep))
 
     def _find_relative_path(self, filename):
         if filename.startswith(self.filename):
@@ -147,7 +147,7 @@
             return fname
 
     def import_py_file(self, space, modname, filename, buf, pkgpath):
-        w_mod = Module(space, space.wrap_fsdecoded(modname))
+        w_mod = Module(space, space.newfilename(modname))
         real_name = self.filename + os.path.sep + self.corr_zname(filename)
         space.setattr(w_mod, space.newtext('__loader__'), self)
         importing._prepare_module(space, w_mod, real_name, pkgpath)
@@ -316,7 +316,7 @@
                 return w_code
         raise oefmt(get_error(space),
                     "Cannot find source or code for %R in %R",
-                    w_fullname, space.wrap_fsdecoded(self.name))
+                    w_fullname, space.newfilename(self.name))
 
     @unwrap_spec(fullname='fsencode')
     def get_source(self, space, fullname):
@@ -337,20 +337,20 @@
             return space.w_None
         raise oefmt(get_error(space),
                     "Cannot find source for %R in %R",
-                    space.wrap_fsdecoded(filename),
-                    space.wrap_fsdecoded(self.name))
+                    space.newfilename(filename),
+                    space.newfilename(self.name))
 
     def get_filename(self, space, w_fullname):
         fullname = space.fsencode_w(w_fullname)
         filename = self.make_filename(fullname)
         for _, is_package, ext in ENUMERATE_EXTS:
             if self.have_modulefile(space, filename + ext):
-                return space.wrap_fsdecoded(self.filename + os.path.sep +
+                return space.newfilename(self.filename + os.path.sep +
                                             self.corr_zname(filename + ext))
         raise oefmt(get_error(space),
                     "Cannot find module %R in %R",
-                    space.wrap_fsdecoded(filename),
-                    space.wrap_fsdecoded(self.name))
+                    space.newfilename(filename),
+                    space.newfilename(self.name))
 
     def is_package(self, space, w_fullname):
         fullname = space.fsencode_w(w_fullname)
@@ -360,12 +360,12 @@
                 return space.newbool(is_package)
         raise oefmt(get_error(space),
                     "Cannot find module %R in %R",
-                    space.wrap_fsdecoded(filename),
-                    space.wrap_fsdecoded(self.name))
+                    space.newfilename(filename),
+                    space.newfilename(self.name))
 
     def getarchive(self, space):
         space = self.space
-        return space.wrap_fsdecoded(self.filename)
+        return space.newfilename(self.filename)
 
     def _find_loader(self, space, fullname):
         filename = self.make_filename(fullname)
@@ -387,7 +387,7 @@
             result = [self, space.newlist([])]
         else:
             result = [space.w_None,
-                      space.newlist([space.wrap_fsdecoded(ns_portion)])]
+                      space.newlist([space.newfilename(ns_portion)])]
         return space.newtuple(result)
 
 def descr_new_zipimporter(space, w_type, w_name):
@@ -423,7 +423,7 @@
         zip_file = RZipFile(filename, 'r')
     except (BadZipfile, OSError):
         raise oefmt(get_error(space), "%R seems not to be a zipfile",
-                    space.wrap_fsdecoded(filename))
+                    space.newfilename(filename))
     except RZlibError as e:
         # in this case, CPython raises the direct exception coming
         # from the zlib module: let's do the same
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to