summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 0cf0022..9dc1d05 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5048,6 +5048,12 @@ posix_fdopen(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i|si", &fd, &mode, &bufsize))
return NULL;
+ if (mode[0] != 'r' && mode[0] != 'w' && mode[0] != 'a') {
+ PyErr_Format(PyExc_ValueError,
+ "invalid file mode '%s'", mode);
+ return NULL;
+ }
+
Py_BEGIN_ALLOW_THREADS
fp = fdopen(fd, mode);
Py_END_ALLOW_THREADS