Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3fd6e2b9
Commit
3fd6e2b9
authored
Feb 07, 2012
by
Brett Cannon
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
466e6a90
9a74c57e
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
15 deletions
+18
-15
Doc/library/os.rst
Doc/library/os.rst
+1
-1
Doc/whatsnew/3.3.rst
Doc/whatsnew/3.3.rst
+1
-1
Lib/os.py
Lib/os.py
+1
-1
Lib/test/test_os.py
Lib/test/test_os.py
+2
-2
Lib/test/test_posix.py
Lib/test/test_posix.py
+4
-4
Misc/NEWS
Misc/NEWS
+4
-1
Modules/posixmodule.c
Modules/posixmodule.c
+5
-5
No files found.
Doc/library/os.rst
View file @
3fd6e2b9
...
...
@@ -769,7 +769,7 @@ as internal buffering of data.
.. versionadded:: 3.3
.. function:: f
d
listdir(fd)
.. function:: flistdir(fd)
Like :func:`listdir`, but uses a file descriptor instead and always returns
strings.
...
...
Doc/whatsnew/3.3.rst
View file @
3fd6e2b9
...
...
@@ -571,7 +571,7 @@ os
* Other new functions:
* :func:`~os.f
d
listdir` (:issue:`10755`)
* :func:`~os.flistdir` (:issue:`10755`)
* :func:`~os.getgrouplist` (:issue:`9344`)
...
...
Lib/os.py
View file @
3fd6e2b9
...
...
@@ -357,7 +357,7 @@ if _exists("openat"):
# whether to follow symlinks
flag
=
0
if
followlinks
else
AT_SYMLINK_NOFOLLOW
names
=
f
d
listdir
(
topfd
)
names
=
flistdir
(
topfd
)
dirs
,
nondirs
=
[],
[]
for
name
in
names
:
# Here, we don't use AT_SYMLINK_NOFOLLOW to be consistent with
...
...
Lib/test/test_os.py
View file @
3fd6e2b9
...
...
@@ -611,8 +611,8 @@ class FwalkTests(WalkTests):
for
root
,
dirs
,
files
,
rootfd
in
os
.
fwalk
(
*
args
):
# check that the FD is valid
os
.
fstat
(
rootfd
)
# check that f
d
listdir() returns consistent information
self
.
assertEqual
(
set
(
os
.
f
d
listdir
(
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:
...
...
Lib/test/test_posix.py
View file @
3fd6e2b9
...
...
@@ -451,18 +451,18 @@ class PosixTester(unittest.TestCase):
if
hasattr
(
posix
,
'listdir'
):
self
.
assertTrue
(
support
.
TESTFN
in
posix
.
listdir
())
@
unittest
.
skipUnless
(
hasattr
(
posix
,
'f
dlistdir'
),
"test needs posix.fd
listdir()"
)
def
test_f
d
listdir
(
self
):
@
unittest
.
skipUnless
(
hasattr
(
posix
,
'f
listdir'
),
"test needs posix.f
listdir()"
)
def
test_flistdir
(
self
):
f
=
posix
.
open
(
posix
.
getcwd
(),
posix
.
O_RDONLY
)
self
.
addCleanup
(
posix
.
close
,
f
)
self
.
assertEqual
(
sorted
(
posix
.
listdir
(
'.'
)),
sorted
(
posix
.
f
d
listdir
(
f
))
sorted
(
posix
.
flistdir
(
f
))
)
# Check that the fd offset was reset (issue #13739)
self
.
assertEqual
(
sorted
(
posix
.
listdir
(
'.'
)),
sorted
(
posix
.
f
d
listdir
(
f
))
sorted
(
posix
.
flistdir
(
f
))
)
def
test_access
(
self
):
...
...
Misc/NEWS
View file @
3fd6e2b9
...
...
@@ -466,6 +466,9 @@ Core and Builtins
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
#
964437
Make
IDLE
help
window
non
-
modal
.
...
...
@@ -1745,7 +1748,7 @@ Library
-
Issue
#
11297
:
Add
collections
.
ChainMap
().
-
Issue
#
10755
:
Add
the
posix
.
f
d
listdir
()
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
.
...
...
Modules/posixmodule.c
View file @
3fd6e2b9
...
...
@@ -2867,12 +2867,12 @@ posix_listdir(PyObject *self, PyObject *args)
}
/* end of posix_listdir */
#ifdef HAVE_FDOPENDIR
PyDoc_STRVAR
(
posix_f
d
listdir__doc__
,
"f
d
listdir(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_f
d
listdir
(
PyObject
*
self
,
PyObject
*
args
)
posix_flistdir
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
d
,
*
v
;
DIR
*
dirp
;
...
...
@@ -2880,7 +2880,7 @@ posix_fdlistdir(PyObject *self, PyObject *args)
int
fd
;
errno
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:f
d
listdir"
,
&
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 @@ static PyMethodDef posix_methods[] = {
#endif
/* HAVE_LINK */
{
"listdir"
,
posix_listdir
,
METH_VARARGS
,
posix_listdir__doc__
},
#ifdef HAVE_FDOPENDIR
{
"f
dlistdir"
,
posix_fdlistdir
,
METH_VARARGS
,
posix_fd
listdir__doc__
},
{
"f
listdir"
,
posix_flistdir
,
METH_VARARGS
,
posix_f
listdir__doc__
},
#endif
{
"lstat"
,
posix_lstat
,
METH_VARARGS
,
posix_lstat__doc__
},
{
"mkdir"
,
posix_mkdir
,
METH_VARARGS
,
posix_mkdir__doc__
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment