[pypy-svn] r76265 - in pypy/branch/unicode_filename-2/pypy/interpreter: . test

afa at codespeak.net afa at codespeak.net
Fri Jul 16 21:51:23 CEST 2010


Author: afa
Date: Fri Jul 16 21:51:22 2010
New Revision: 76265

Modified:
   pypy/branch/unicode_filename-2/pypy/interpreter/baseobjspace.py
   pypy/branch/unicode_filename-2/pypy/interpreter/gateway.py
   pypy/branch/unicode_filename-2/pypy/interpreter/test/test_gateway.py
Log:
Remove space.path_w() and the 'path' unwrap_spec:
it's wrong to unconditionally encode file names (the conversion loses characters on Windows)
a better logic is implemented by interp_posix.


Modified: pypy/branch/unicode_filename-2/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/branch/unicode_filename-2/pypy/interpreter/baseobjspace.py	Fri Jul 16 21:51:22 2010
@@ -1102,17 +1102,6 @@
                                  self.wrap('argument must be a unicode'))
         return self.unicode_w(w_obj)
 
-    def path_w(self, w_obj):
-        """ Like str_w, but if the object is unicode, encode it using
-        filesystemencoding
-        """
-        filesystemencoding = self.sys.filesystemencoding
-        if (filesystemencoding and
-            self.is_true(self.isinstance(w_obj, self.w_unicode))):
-            w_obj = self.call_method(w_obj, "encode",
-                                     self.wrap(filesystemencoding))
-        return self.str_w(w_obj)
-
     def bool_w(self, w_obj):
         # Unwraps a bool, also accepting an int for compatibility.
         # This is here mostly just for gateway.int_unwrapping_space_method().

Modified: pypy/branch/unicode_filename-2/pypy/interpreter/gateway.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/interpreter/gateway.py	(original)
+++ pypy/branch/unicode_filename-2/pypy/interpreter/gateway.py	Fri Jul 16 21:51:22 2010
@@ -137,9 +137,6 @@
     def visit_c_nonnegint(self, el, app_sig):
         self.checked_space_method(el, app_sig)
 
-    def visit_path(self, el, app_sig):
-        self.checked_space_method(el, app_sig)
-
     def visit__Wrappable(self, el, app_sig):
         name = el.__name__
         argname = self.orig_arg()
@@ -241,9 +238,6 @@
     def visit_bufferstr(self, typ):
         self.run_args.append("space.bufferstr_w(%s)" % (self.scopenext(),))
 
-    def visit_path(self, typ):
-        self.run_args.append("space.path_w(%s)" % (self.scopenext(),))
-
     def visit_nonnegint(self, typ):
         self.run_args.append("space.nonnegint_w(%s)" % (self.scopenext(),))
 
@@ -371,9 +365,6 @@
     def visit_bufferstr(self, typ):
         self.unwrap.append("space.bufferstr_w(%s)" % (self.nextarg(),))
 
-    def visit_path(self, typ):
-        self.unwrap.append("space.path_w(%s)" % (self.nextarg(),))
-
     def visit_nonnegint(self, typ):
         self.unwrap.append("space.nonnegint_w(%s)" % (self.nextarg(),))
 

Modified: pypy/branch/unicode_filename-2/pypy/interpreter/test/test_gateway.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/interpreter/test/test_gateway.py	(original)
+++ pypy/branch/unicode_filename-2/pypy/interpreter/test/test_gateway.py	Fri Jul 16 21:51:22 2010
@@ -454,16 +454,6 @@
         assert len(l) == 1
         assert space.eq_w(l[0], w("foo"))
 
-    def test_interp2app_unwrap_spec_path(self, monkeypatch):
-        space = self.space
-        def g(space, p):
-            return p
-
-        app_g = gateway.interp2app(g, unwrap_spec=[gateway.ObjSpace, 'path'])
-        w_app_g = space.wrap(app_g)
-        monkeypatch.setattr(space.sys, "filesystemencoding", "utf-8")
-        w_res = space.call_function(w_app_g, space.wrap(u"ą"))
-
     def test_interp2app_classmethod(self):
         space = self.space
         w = space.wrap



More information about the Pypy-commit mailing list