Merge
This commit is contained in:
commit
3fd6e2b910
|
@ -769,7 +769,7 @@ as internal buffering of data.
|
||||||
.. versionadded:: 3.3
|
.. versionadded:: 3.3
|
||||||
|
|
||||||
|
|
||||||
.. function:: fdlistdir(fd)
|
.. function:: flistdir(fd)
|
||||||
|
|
||||||
Like :func:`listdir`, but uses a file descriptor instead and always returns
|
Like :func:`listdir`, but uses a file descriptor instead and always returns
|
||||||
strings.
|
strings.
|
||||||
|
|
|
@ -571,7 +571,7 @@ os
|
||||||
|
|
||||||
* Other new functions:
|
* Other new functions:
|
||||||
|
|
||||||
* :func:`~os.fdlistdir` (:issue:`10755`)
|
* :func:`~os.flistdir` (:issue:`10755`)
|
||||||
* :func:`~os.getgrouplist` (:issue:`9344`)
|
* :func:`~os.getgrouplist` (:issue:`9344`)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -357,7 +357,7 @@ if _exists("openat"):
|
||||||
# whether to follow symlinks
|
# whether to follow symlinks
|
||||||
flag = 0 if followlinks else AT_SYMLINK_NOFOLLOW
|
flag = 0 if followlinks else AT_SYMLINK_NOFOLLOW
|
||||||
|
|
||||||
names = fdlistdir(topfd)
|
names = flistdir(topfd)
|
||||||
dirs, nondirs = [], []
|
dirs, nondirs = [], []
|
||||||
for name in names:
|
for name in names:
|
||||||
# Here, we don't use AT_SYMLINK_NOFOLLOW to be consistent with
|
# Here, we don't use AT_SYMLINK_NOFOLLOW to be consistent with
|
||||||
|
|
|
@ -611,8 +611,8 @@ class FwalkTests(WalkTests):
|
||||||
for root, dirs, files, rootfd in os.fwalk(*args):
|
for root, dirs, files, rootfd in os.fwalk(*args):
|
||||||
# check that the FD is valid
|
# check that the FD is valid
|
||||||
os.fstat(rootfd)
|
os.fstat(rootfd)
|
||||||
# check that fdlistdir() returns consistent information
|
# check that flistdir() returns consistent information
|
||||||
self.assertEqual(set(os.fdlistdir(rootfd)), set(dirs) | set(files))
|
self.assertEqual(set(os.flistdir(rootfd)), set(dirs) | set(files))
|
||||||
|
|
||||||
def test_fd_leak(self):
|
def test_fd_leak(self):
|
||||||
# Since we're opening a lot of FDs, we must be careful to avoid leaks:
|
# Since we're opening a lot of FDs, we must be careful to avoid leaks:
|
||||||
|
|
|
@ -451,18 +451,18 @@ class PosixTester(unittest.TestCase):
|
||||||
if hasattr(posix, 'listdir'):
|
if hasattr(posix, 'listdir'):
|
||||||
self.assertTrue(support.TESTFN in posix.listdir())
|
self.assertTrue(support.TESTFN in posix.listdir())
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(posix, 'fdlistdir'), "test needs posix.fdlistdir()")
|
@unittest.skipUnless(hasattr(posix, 'flistdir'), "test needs posix.flistdir()")
|
||||||
def test_fdlistdir(self):
|
def test_flistdir(self):
|
||||||
f = posix.open(posix.getcwd(), posix.O_RDONLY)
|
f = posix.open(posix.getcwd(), posix.O_RDONLY)
|
||||||
self.addCleanup(posix.close, f)
|
self.addCleanup(posix.close, f)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(posix.listdir('.')),
|
sorted(posix.listdir('.')),
|
||||||
sorted(posix.fdlistdir(f))
|
sorted(posix.flistdir(f))
|
||||||
)
|
)
|
||||||
# Check that the fd offset was reset (issue #13739)
|
# Check that the fd offset was reset (issue #13739)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(posix.listdir('.')),
|
sorted(posix.listdir('.')),
|
||||||
sorted(posix.fdlistdir(f))
|
sorted(posix.flistdir(f))
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_access(self):
|
def test_access(self):
|
||||||
|
|
|
@ -466,6 +466,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #10811: Fix recursive usage of cursors. Instead of crashing,
|
||||||
|
raise a ProgrammingError now.
|
||||||
|
|
||||||
- Issue #10881: Fix test_site failure with OS X framework builds.
|
- Issue #10881: Fix test_site failure with OS X framework builds.
|
||||||
|
|
||||||
- Issue #964437 Make IDLE help window non-modal.
|
- Issue #964437 Make IDLE help window non-modal.
|
||||||
|
@ -1745,7 +1748,7 @@ Library
|
||||||
|
|
||||||
- Issue #11297: Add collections.ChainMap().
|
- 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
|
- Issue #4761: Add the *at() family of functions (openat(), etc.) to the posix
|
||||||
module. Patch by Ross Lagerwall.
|
module. Patch by Ross Lagerwall.
|
||||||
|
|
|
@ -2867,12 +2867,12 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||||
} /* end of posix_listdir */
|
} /* end of posix_listdir */
|
||||||
|
|
||||||
#ifdef HAVE_FDOPENDIR
|
#ifdef HAVE_FDOPENDIR
|
||||||
PyDoc_STRVAR(posix_fdlistdir__doc__,
|
PyDoc_STRVAR(posix_flistdir__doc__,
|
||||||
"fdlistdir(fd) -> list_of_strings\n\n\
|
"flistdir(fd) -> list_of_strings\n\n\
|
||||||
Like listdir(), but uses a file descriptor instead.");
|
Like listdir(), but uses a file descriptor instead.");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
posix_fdlistdir(PyObject *self, PyObject *args)
|
posix_flistdir(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *d, *v;
|
PyObject *d, *v;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
|
@ -2880,7 +2880,7 @@ posix_fdlistdir(PyObject *self, PyObject *args)
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (!PyArg_ParseTuple(args, "i:fdlistdir", &fd))
|
if (!PyArg_ParseTuple(args, "i:flistdir", &fd))
|
||||||
return NULL;
|
return NULL;
|
||||||
/* closedir() closes the FD, so we duplicate it */
|
/* closedir() closes the FD, so we duplicate it */
|
||||||
fd = dup(fd);
|
fd = dup(fd);
|
||||||
|
@ -10555,7 +10555,7 @@ static PyMethodDef posix_methods[] = {
|
||||||
#endif /* HAVE_LINK */
|
#endif /* HAVE_LINK */
|
||||||
{"listdir", posix_listdir, METH_VARARGS, posix_listdir__doc__},
|
{"listdir", posix_listdir, METH_VARARGS, posix_listdir__doc__},
|
||||||
#ifdef HAVE_FDOPENDIR
|
#ifdef HAVE_FDOPENDIR
|
||||||
{"fdlistdir", posix_fdlistdir, METH_VARARGS, posix_fdlistdir__doc__},
|
{"flistdir", posix_flistdir, METH_VARARGS, posix_flistdir__doc__},
|
||||||
#endif
|
#endif
|
||||||
{"lstat", posix_lstat, METH_VARARGS, posix_lstat__doc__},
|
{"lstat", posix_lstat, METH_VARARGS, posix_lstat__doc__},
|
||||||
{"mkdir", posix_mkdir, METH_VARARGS, posix_mkdir__doc__},
|
{"mkdir", posix_mkdir, METH_VARARGS, posix_mkdir__doc__},
|
||||||
|
|
Loading…
Reference in New Issue