Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 23554:e5242f58a5b6 legacy-trunk
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.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Tue, 28 May 2002 10:58:19 +0000 |
| parents | 8291473fde3e |
| children | 0e8370e70888 |
line wrap: on
line diff
--- a/Python/import.c Tue May 28 08:04:00 2002 +0000 +++ b/Python/import.c Tue May 28 10:58:19 2002 +0000 @@ -81,15 +81,15 @@ #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 @@ 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 @@ 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;
