Author: Armin Rigo <[email protected]>
Branch: py3.5-scandir
Changeset: r86399:bcb73d504b55
Date: 2016-08-22 10:32 +0200
http://bitbucket.org/pypy/pypy/changeset/bcb73d504b55/

Log:    Fix os.scandir(None), and os.scandir(dirfd) does not work on cpython
        either

diff --git a/pypy/module/posix/interp_scandir.py 
b/pypy/module/posix/interp_scandir.py
--- a/pypy/module/posix/interp_scandir.py
+++ b/pypy/module/posix/interp_scandir.py
@@ -11,21 +11,16 @@
 from pypy.module.posix.interp_posix import unwrap_fd, build_stat_result
 
 
-@unwrap_spec(w_path=WrappedDefault(u"."))
-def scandir(space, w_path):
+def scandir(space, w_path=None):
     "scandir(path='.') -> iterator of DirEntry objects for given path"
 
+    if space.is_none(w_path):
+        w_path = space.newunicode(u".")
     if space.isinstance_w(w_path, space.w_bytes):
         path_bytes = space.str0_w(w_path)
         result_is_bytes = True
     else:
-        try:
-            path_bytes = space.fsencode_w(w_path)
-        except OperationError as operr:
-            if operr.async(space):
-                raise
-            fd = unwrap_fd(space, w_path, "string, bytes or integer")
-            XXXX
+        path_bytes = space.fsencode_w(w_path)
         result_is_bytes = False
 
     try:
diff --git a/pypy/module/posix/test/test_scandir.py 
b/pypy/module/posix/test/test_scandir.py
--- a/pypy/module/posix/test/test_scandir.py
+++ b/pypy/module/posix/test/test_scandir.py
@@ -61,6 +61,10 @@
         assert type(d.name) is str
         assert type(d.path) is str
         assert d.path == './' + d.name
+        d = next(posix.scandir(None))
+        assert type(d.name) is str
+        assert type(d.path) is str
+        assert d.path == './' + d.name
         d = next(posix.scandir(u'.'))
         assert type(d.name) is str
         assert type(d.path) is str
@@ -149,3 +153,7 @@
         raises(OSError, d.is_file)
         raises(OSError, d.is_dir)
         assert d.is_symlink()
+
+    def test_fdopendir_unsupported(self):
+        posix = self.posix
+        raises(TypeError, posix.scandir, 1234)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to