diff Python/import.c @ 23586:fba57e40f547 legacy-trunk

imp_load_module(): correct and comment the sense of the test for '+' in the mode (it's forbidden).
author Guido van Rossum <guido@python.org>
date Thu, 30 May 2002 17:33:07 +0000
parents 0e8370e70888
children ed1ba37a46b7
line wrap: on
line diff
--- a/Python/import.c	Thu May 30 17:15:25 2002 +0000
+++ b/Python/import.c	Thu May 30 17:33:07 2002 +0000
@@ -2408,11 +2408,16 @@
 			      &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;