Commits

Amaury Forgeot d'Arc committed fa19020

Fix os.getcwdu() to return a unicode as advertised.
This fixes the last failure on Windows!

Comments (0)

Files changed (2)

pypy/module/posix/interp_posix.py

 
 def getcwdu(space):
     """Return a unicode string representing the current working directory."""
-    try:
-        cur = os.getcwdu()
-    except OSError, e: 
-        raise wrap_oserror(space, e) 
-    else: 
+    if _WIN:
+        try:
+            cur = os.getcwdu()
+        except OSError, e: 
+            raise wrap_oserror(space, e)
         return space.wrap(cur)
+    else:
+        # XXX sys.getfilesystemencoding() is None on Linux
+        return space.call_method(getcwd(space), 'decode')
 getcwd.unwrap_spec = [ObjSpace]
 
 def chdir(space, w_path):

pypy/rpython/module/ll_os.py

             tp = str
             TP = rffi.CCHARP
             charp2str = rffi.charp2str
+            fnname = underscore_on_windows + 'getcwd'
         else:
             tp = unicode
             TP = rffi.CWCHARP
             charp2str = rffi.wcharp2unicode
-        os_getcwd = self.llexternal(underscore_on_windows + 'getcwd',
+            fnname = underscore_on_windows + 'wgetcwd'
+        os_getcwd = self.llexternal(fnname,
                                     [TP, rffi.SIZE_T],
                                     TP)
 
 
     @registering(os.getcwdu)
     def register_os_getcwdu(self):
+        # XXX only on Windows!
         return self.register_os_getcwd(unicodepath=True)
 
     @registering(os.listdir)