Issue #13739: It's simpler and more direct to call rewinddir() at the

beginning.
parent 7546ad32
...@@ -2890,6 +2890,7 @@ posix_fdlistdir(PyObject *self, PyObject *args) ...@@ -2890,6 +2890,7 @@ posix_fdlistdir(PyObject *self, PyObject *args)
close(fd); close(fd);
return posix_error(); return posix_error();
} }
rewinddir(dirp);
if ((d = PyList_New(0)) == NULL) { if ((d = PyList_New(0)) == NULL) {
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
closedir(dirp); closedir(dirp);
...@@ -2906,7 +2907,6 @@ posix_fdlistdir(PyObject *self, PyObject *args) ...@@ -2906,7 +2907,6 @@ posix_fdlistdir(PyObject *self, PyObject *args)
break; break;
} else { } else {
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
rewinddir(dirp);
closedir(dirp); closedir(dirp);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
Py_DECREF(d); Py_DECREF(d);
...@@ -2930,7 +2930,6 @@ posix_fdlistdir(PyObject *self, PyObject *args) ...@@ -2930,7 +2930,6 @@ posix_fdlistdir(PyObject *self, PyObject *args)
Py_DECREF(v); Py_DECREF(v);
} }
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
rewinddir(dirp);
closedir(dirp); closedir(dirp);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment