diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-05-28 10:58:19 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-05-28 10:58:19 (GMT) |
commit | c88da1faa5bfa9b72b38822cb9745ad7be7606a3 (patch) | |
tree | af153a2eb4a0f8dc127f24e03c8d34f011ab7085 /Python/import.c | |
parent | 313a7513b0c5771042d850d70782a2448d1cdcb7 (diff) | |
download | cpython-c88da1faa5bfa9b72b38822cb9745ad7be7606a3.zip cpython-c88da1faa5bfa9b72b38822cb9745ad7be7606a3.tar.gz cpython-c88da1faa5bfa9b72b38822cb9745ad7be7606a3.tar.bz2 |
File modes in filedescr entries are also passed to Python, so we now put "U"
in there, and convert it to "rb" (or "r" for non-universal-newline builds)
before passing it to fopen().
Fixes #561326.
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Python/import.c b/Python/import.c index 3775f88..5c53813 100644 --- a/Python/import.c +++ b/Python/import.c @@ -81,15 +81,15 @@ struct filedescr * _PyImport_Filetab = NULL; #ifdef RISCOS static const struct filedescr _PyImport_StandardFiletab[] = { - {"/py", "r" PY_STDIOTEXTMODE, PY_SOURCE}, + {"/py", "U", PY_SOURCE}, {"/pyc", "rb", PY_COMPILED}, {0, 0} }; #else static const struct filedescr _PyImport_StandardFiletab[] = { - {".py", "r" PY_STDIOTEXTMODE, PY_SOURCE}, + {".py", "U", PY_SOURCE}, #ifdef MS_WIN32 - {".pyw", "r" PY_STDIOTEXTMODE, PY_SOURCE}, + {".pyw", "U", PY_SOURCE}, #endif {".pyc", "rb", PY_COMPILED}, {0, 0} @@ -892,6 +892,7 @@ find_module(char *realname, PyObject *path, char *buf, size_t buflen, int i, npath; size_t len, namelen; struct filedescr *fdp = NULL; + char *filemode; FILE *fp = NULL; #ifndef RISCOS struct stat statbuf; @@ -1065,7 +1066,9 @@ find_module(char *realname, PyObject *path, char *buf, size_t buflen, if (Py_VerboseFlag > 1) PySys_WriteStderr("# trying %s\n", buf); #endif /* !macintosh */ - fp = fopen(buf, fdp->mode); + filemode = fdp->mode; + if (filemode[0] == 'U') filemode = "r" PY_STDIOTEXTMODE; + fp = fopen(buf, filemode); if (fp != NULL) { if (case_ok(buf, len, namelen, name)) break; |