diff options
author | Guido van Rossum <guido@python.org> | 2000-03-31 00:47:28 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-03-31 00:47:28 (GMT) |
commit | ffd15f5255a600fe6cb6fb38123d58eca51f9987 (patch) | |
tree | 51336654c93c0e3059eaea02c4bb32e692e60ede /Modules | |
parent | fb2789f387029f54ac386d923866e6931f95d661 (diff) | |
download | cpython-ffd15f5255a600fe6cb6fb38123d58eca51f9987.zip cpython-ffd15f5255a600fe6cb6fb38123d58eca51f9987.tar.gz cpython-ffd15f5255a600fe6cb6fb38123d58eca51f9987.tar.bz2 |
Two robustness patches:
(1) In opendir(), don't call the lock-release macros; we're
manipulating list objects and that shouldn't be done in unlocked
state.
(2) Don't use posix_strint() for chmod() -- the mode_t arg might be a
64 bit int (reported by Nick Maclaren).
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/posixmodule.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 8ae5d2f..f5ac1d5 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -692,7 +692,18 @@ posix_chmod(self, args) PyObject *self; PyObject *args; { - return posix_strint(args, "si:chmod", chmod); + char *path; + int i; + int res; + if (!PyArg_ParseTuple(args, format, &path, &i)) + return NULL; + Py_BEGIN_ALLOW_THREADS + res = chmod(path, i); + Py_END_ALLOW_THREADS + if (res < 0) + return posix_error_with_filename(path); + Py_INCREF(Py_None); + return Py_None; } @@ -998,14 +1009,11 @@ posix_listdir(self, args) struct dirent *ep; if (!PyArg_ParseTuple(args, "s:listdir", &name)) return NULL; - Py_BEGIN_ALLOW_THREADS if ((dirp = opendir(name)) == NULL) { - Py_BLOCK_THREADS return posix_error_with_filename(name); } if ((d = PyList_New(0)) == NULL) { closedir(dirp); - Py_BLOCK_THREADS return NULL; } while ((ep = readdir(dirp)) != NULL) { @@ -1028,7 +1036,6 @@ posix_listdir(self, args) Py_DECREF(v); } closedir(dirp); - Py_END_ALLOW_THREADS return d; |