summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-05-30 17:33:07 (GMT)
committerGuido van Rossum <guido@python.org>2002-05-30 17:33:07 (GMT)
commit5e2c5fa1bd9f0ed602ce2977c7c6772433c8de4d (patch)
tree07708800f38d2d5aae1ca11b0005e33ca3d0ea6c
parent4ae6faed9f618c53c42816e868c4cb7194cd045f (diff)
downloadcpython-5e2c5fa1bd9f0ed602ce2977c7c6772433c8de4d.zip
cpython-5e2c5fa1bd9f0ed602ce2977c7c6772433c8de4d.tar.gz
cpython-5e2c5fa1bd9f0ed602ce2977c7c6772433c8de4d.tar.bz2
imp_load_module(): correct and comment the sense of the test for '+'
in the mode (it's forbidden).
-rw-r--r--Python/import.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index 112f7f6..8c9cd2f 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -2408,11 +2408,16 @@ imp_load_module(PyObject *self, PyObject *args)
&name, &fob, &pathname,
&suffix, &mode, &type))
return NULL;
- if (*mode &&
- !(*mode == 'r' || *mode == 'U' || strchr(mode, '+'))) {
+ if (*mode) {
+ /* Mode must start with 'r' or 'U' and must not contain '+'.
+ Implicit in this test is the assumption that the mode
+ may contain other modifiers like 'b' or 't'. */
+
+ if (!(*mode == 'r' || *mode == 'U') || strchr(mode, '+')) {
PyErr_Format(PyExc_ValueError,
"invalid file open mode %.200s", mode);
return NULL;
+ }
}
if (fob == Py_None)
fp = NULL;