[Python-checkins] cpython: Following Nick's suggestion, rename posix.fdlistdir() to posix.flistdir(), to

charles-francois.natali python-checkins at python.org
Mon Feb 6 19:55:43 CET 2012


http://hg.python.org/cpython/rev/015936cec930
changeset:   74810:015936cec930
user:        Charles-François Natali <neologix at free.fr>
date:        Mon Feb 06 19:54:48 2012 +0100
summary:
  Following Nick's suggestion, rename posix.fdlistdir() to posix.flistdir(), to
be consistent with other functions accepting file descriptors (fdlistdir() was
added in 3.3, so hasn't been released yet).

files:
  Doc/library/os.rst     |   2 +-
  Doc/whatsnew/3.3.rst   |   2 +-
  Lib/os.py              |   2 +-
  Lib/test/test_os.py    |   4 ++--
  Lib/test/test_posix.py |   8 ++++----
  Misc/NEWS              |   2 +-
  Modules/posixmodule.c  |  10 +++++-----
  7 files changed, 15 insertions(+), 15 deletions(-)


diff --git a/Doc/library/os.rst b/Doc/library/os.rst
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -769,7 +769,7 @@
    .. versionadded:: 3.3
 
 
-.. function:: fdlistdir(fd)
+.. function:: flistdir(fd)
 
    Like :func:`listdir`, but uses a file descriptor instead and always returns
    strings.
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst
--- a/Doc/whatsnew/3.3.rst
+++ b/Doc/whatsnew/3.3.rst
@@ -571,7 +571,7 @@
 
 * Other new functions:
 
-  * :func:`~os.fdlistdir` (:issue:`10755`)
+  * :func:`~os.flistdir` (:issue:`10755`)
   * :func:`~os.getgrouplist` (:issue:`9344`)
 
 
diff --git a/Lib/os.py b/Lib/os.py
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -357,7 +357,7 @@
         # whether to follow symlinks
         flag = 0 if followlinks else AT_SYMLINK_NOFOLLOW
 
-        names = fdlistdir(topfd)
+        names = flistdir(topfd)
         dirs, nondirs = [], []
         for name in names:
             # Here, we don't use AT_SYMLINK_NOFOLLOW to be consistent with
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -611,8 +611,8 @@
             for root, dirs, files, rootfd in os.fwalk(*args):
                 # check that the FD is valid
                 os.fstat(rootfd)
-                # check that fdlistdir() returns consistent information
-                self.assertEqual(set(os.fdlistdir(rootfd)), set(dirs) | set(files))
+                # check that flistdir() returns consistent information
+                self.assertEqual(set(os.flistdir(rootfd)), set(dirs) | set(files))
 
     def test_fd_leak(self):
         # Since we're opening a lot of FDs, we must be careful to avoid leaks:
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -451,18 +451,18 @@
         if hasattr(posix, 'listdir'):
             self.assertTrue(support.TESTFN in posix.listdir())
 
-    @unittest.skipUnless(hasattr(posix, 'fdlistdir'), "test needs posix.fdlistdir()")
-    def test_fdlistdir(self):
+    @unittest.skipUnless(hasattr(posix, 'flistdir'), "test needs posix.flistdir()")
+    def test_flistdir(self):
         f = posix.open(posix.getcwd(), posix.O_RDONLY)
         self.addCleanup(posix.close, f)
         self.assertEqual(
             sorted(posix.listdir('.')),
-            sorted(posix.fdlistdir(f))
+            sorted(posix.flistdir(f))
             )
         # Check that the fd offset was reset (issue #13739)
         self.assertEqual(
             sorted(posix.listdir('.')),
-            sorted(posix.fdlistdir(f))
+            sorted(posix.flistdir(f))
             )
 
     def test_access(self):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1745,7 +1745,7 @@
 
 - Issue #11297: Add collections.ChainMap().
 
-- Issue #10755: Add the posix.fdlistdir() function.  Patch by Ross Lagerwall.
+- Issue #10755: Add the posix.flistdir() function.  Patch by Ross Lagerwall.
 
 - Issue #4761: Add the *at() family of functions (openat(), etc.) to the posix
   module.  Patch by Ross Lagerwall.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2867,12 +2867,12 @@
 }  /* end of posix_listdir */
 
 #ifdef HAVE_FDOPENDIR
-PyDoc_STRVAR(posix_fdlistdir__doc__,
-"fdlistdir(fd) -> list_of_strings\n\n\
+PyDoc_STRVAR(posix_flistdir__doc__,
+"flistdir(fd) -> list_of_strings\n\n\
 Like listdir(), but uses a file descriptor instead.");
 
 static PyObject *
-posix_fdlistdir(PyObject *self, PyObject *args)
+posix_flistdir(PyObject *self, PyObject *args)
 {
     PyObject *d, *v;
     DIR *dirp;
@@ -2880,7 +2880,7 @@
     int fd;
 
     errno = 0;
-    if (!PyArg_ParseTuple(args, "i:fdlistdir", &fd))
+    if (!PyArg_ParseTuple(args, "i:flistdir", &fd))
         return NULL;
     /* closedir() closes the FD, so we duplicate it */
     fd = dup(fd);
@@ -10555,7 +10555,7 @@
 #endif /* HAVE_LINK */
     {"listdir",         posix_listdir, METH_VARARGS, posix_listdir__doc__},
 #ifdef HAVE_FDOPENDIR
-    {"fdlistdir",       posix_fdlistdir, METH_VARARGS, posix_fdlistdir__doc__},
+    {"flistdir",       posix_flistdir, METH_VARARGS, posix_flistdir__doc__},
 #endif
     {"lstat",           posix_lstat, METH_VARARGS, posix_lstat__doc__},
     {"mkdir",           posix_mkdir, METH_VARARGS, posix_mkdir__doc__},

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list