[pypy-svn] r76164 - in pypy/branch/unicode_filename-2/pypy: module/posix module/posix/test rlib/test rpython/module

afa at codespeak.net afa at codespeak.net
Mon Jul 12 22:28:03 CEST 2010


Author: afa
Date: Mon Jul 12 22:28:02 2010
New Revision: 76164

Modified:
   pypy/branch/unicode_filename-2/pypy/module/posix/interp_posix.py
   pypy/branch/unicode_filename-2/pypy/module/posix/test/test_posix2.py
   pypy/branch/unicode_filename-2/pypy/rlib/test/test_rposix.py
   pypy/branch/unicode_filename-2/pypy/rpython/module/ll_os.py
Log:
Add an interp-level test


Modified: pypy/branch/unicode_filename-2/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/module/posix/interp_posix.py	(original)
+++ pypy/branch/unicode_filename-2/pypy/module/posix/interp_posix.py	Mon Jul 12 22:28:02 2010
@@ -20,6 +20,9 @@
     def encode(self):
         return self.space.path_w(self.w_obj)
 
+    def gettext(self):
+        return self.space.unicode_w(self.w_obj)
+
 def open(space, w_fname, flag, mode=0777):
     """Open a file (for low level IO).
 Return a file descriptor (a small integer)."""

Modified: pypy/branch/unicode_filename-2/pypy/module/posix/test/test_posix2.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/module/posix/test/test_posix2.py	(original)
+++ pypy/branch/unicode_filename-2/pypy/module/posix/test/test_posix2.py	Mon Jul 12 22:28:02 2010
@@ -706,6 +706,25 @@
         except OSError:
             pass
 
+class AppTestUnicodeFilename:
+    def setup_class(cls):
+        ufilename = (unicode(udir.join('test_unicode_filename_')) +
+                     u'\u65e5\u672c.txt') # "Japan"
+        f = file(ufilename, 'w')
+        f.write("test")
+        f.close()
+        cls.space = space
+        cls.w_filename = space.wrap(ufilename)
+        cls.w_posix = space.appexec([], GET_POSIX)
+
+    def test_open(self):
+        fd = self.posix.open(self.filename, self.posix.O_RDONLY)
+        try:
+            content = self.posix.read(fd, 50)
+        finally:
+            self.posix.close(fd)
+        assert content == "test"
+
 
 class TestPexpect(object):
     # XXX replace with AppExpectTest class as soon as possible

Modified: pypy/branch/unicode_filename-2/pypy/rlib/test/test_rposix.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/rlib/test/test_rposix.py	(original)
+++ pypy/branch/unicode_filename-2/pypy/rlib/test/test_rposix.py	Mon Jul 12 22:28:02 2010
@@ -23,6 +23,10 @@
                 from pypy.rlib.runicode import unicode_encode_utf_8
                 return unicode_encode_utf_8(self.unistr, len(self.unistr),
                                             "strict")
+
+            def gettext(self):
+                return self.unistr
+
         path = UnicodeWithEncoding(ufilename)
 
         def f():

Modified: pypy/branch/unicode_filename-2/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/rpython/module/ll_os.py	(original)
+++ pypy/branch/unicode_filename-2/pypy/rpython/module/ll_os.py	Mon Jul 12 22:28:02 2010
@@ -35,7 +35,7 @@
     strings.  Replaces the corresponding function in pypy.rlib.rposix.
     """
     def unicodefunc(*args):
-        raise NotImplementedError
+        return func(*args)
 
     argnum = argnums[0]
     unrolling_args = unrolling_iterable(enumerate([i in argnums
@@ -53,12 +53,12 @@
             real_args = ()
             for i, isunicode in unrolling_args:
                 if isunicode:
-                    real_args += (args[i].unistr,)
+                    real_args += (args[i].gettext(),)
                 else:
                     real_args += (args[i],)
             return unicodefunc(*real_args)
     if condition:
-        rposix_func._flowspace_rewrite_directly_as_ = new_func
+        setattr(rposix, func_name, new_func)
 
     return registering(unicodefunc, condition=condition)
 



More information about the Pypy-commit mailing list