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
86cbf81b
Commit
86cbf81b
authored
Jul 16, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1608818: errno can get set by every call to readdir().
parent
b32dea5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
Misc/NEWS
Misc/NEWS
+2
-0
Modules/posixmodule.c
Modules/posixmodule.c
+10
-8
No files found.
Misc/NEWS
View file @
86cbf81b
...
...
@@ -63,6 +63,8 @@ Core and Builtins
Library
-------
- Issue #1608818: Fix misbehavior in os.listdir() if readdir() fails.
- Issue #3125: Remove copy_reg in multiprocessing and replace it with
ForkingPickler.register() to resolve conflict with ctypes.
...
...
Modules/posixmodule.c
View file @
86cbf81b
...
...
@@ -2322,11 +2322,19 @@ posix_listdir(PyObject *self, PyObject *args)
return
NULL
;
}
for
(;;)
{
errno
=
0
;
Py_BEGIN_ALLOW_THREADS
ep
=
readdir
(
dirp
);
Py_END_ALLOW_THREADS
if
(
ep
==
NULL
)
break
;
if
(
ep
==
NULL
)
{
if
(
errno
==
0
)
{
break
;
}
else
{
closedir
(
dirp
);
Py_DECREF
(
d
);
return
posix_error_with_allocated_filename
(
name
);
}
}
if
(
ep
->
d_name
[
0
]
==
'.'
&&
(
NAMLEN
(
ep
)
==
1
||
(
ep
->
d_name
[
1
]
==
'.'
&&
NAMLEN
(
ep
)
==
2
)))
...
...
@@ -2363,12 +2371,6 @@ posix_listdir(PyObject *self, PyObject *args)
}
Py_DECREF
(
v
);
}
if
(
errno
!=
0
&&
d
!=
NULL
)
{
/* readdir() returned NULL and set errno */
closedir
(
dirp
);
Py_DECREF
(
d
);
return
posix_error_with_allocated_filename
(
name
);
}
closedir
(
dirp
);
PyMem_Free
(
name
);
...
...
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