Amaury Forgeot d'Arc avatar 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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.