diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-04-14 20:12:41 +0000 |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-04-14 20:12:41 +0000 |
commit | 7b8c7546ebc1fc3688ef95768fa8b82f0f205490 (patch) | |
tree | 2e14b243347a9c38c82e2e774d4b201f23149916 /Python | |
parent | dcd2dc2fffce8614c5d2b8d303a303a599b88a23 (diff) | |
download | cpython-git-7b8c7546ebc1fc3688ef95768fa8b82f0f205490.tar.gz |
Mass checkin of universal newline support.
Highlights: import and friends will understand any of \r, \n and \r\n
as end of line. Python file input will do the same if you use mode 'U'.
Everything can be disabled by configuring with --without-universal-newlines.
See PEP278 for details.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 2 | ||||
-rw-r--r-- | Python/errors.c | 4 | ||||
-rw-r--r-- | Python/import.c | 6 | ||||
-rw-r--r-- | Python/traceback.c | 6 |
4 files changed, 9 insertions, 9 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 35536d99d2..680152d510 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -594,7 +594,7 @@ builtin_execfile(PyObject *self, PyObject *args) if (exists) { Py_BEGIN_ALLOW_THREADS - fp = fopen(filename, "r"); + fp = fopen(filename, "r" PY_STDIOTEXTMODE); Py_END_ALLOW_THREADS if (fp == NULL) { diff --git a/Python/errors.c b/Python/errors.c index 3869b1cc5c..265e5bb48e 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -646,14 +646,14 @@ PyErr_ProgramText(char *filename, int lineno) if (filename == NULL || lineno <= 0) return NULL; - fp = fopen(filename, "r"); + fp = fopen(filename, "r" PY_STDIOTEXTMODE); if (fp == NULL) return NULL; for (i = 0; i < lineno; i++) { char *pLastChar = &linebuf[sizeof(linebuf) - 2]; do { *pLastChar = '\0'; - if (fgets(linebuf, sizeof linebuf, fp) == NULL) + if (Py_UniversalNewlineFgets(linebuf, sizeof linebuf, fp, NULL) == NULL) break; /* fgets read *something*; if it didn't get as far as pLastChar, it must have found a newline diff --git a/Python/import.c b/Python/import.c index 3c8750671e..3775f886e3 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_SOURCE}, + {"/py", "r" PY_STDIOTEXTMODE, PY_SOURCE}, {"/pyc", "rb", PY_COMPILED}, {0, 0} }; #else static const struct filedescr _PyImport_StandardFiletab[] = { - {".py", "r", PY_SOURCE}, + {".py", "r" PY_STDIOTEXTMODE, PY_SOURCE}, #ifdef MS_WIN32 - {".pyw", "r", PY_SOURCE}, + {".pyw", "r" PY_STDIOTEXTMODE, PY_SOURCE}, #endif {".pyc", "rb", PY_COMPILED}, {0, 0} diff --git a/Python/traceback.c b/Python/traceback.c index 52f3202ad5..de918f9a20 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -155,7 +155,7 @@ tb_displayline(PyObject *f, char *filename, int lineno, char *name) /* This is needed by Emacs' compile command */ #define FMT " File \"%.500s\", line %d, in %.500s\n" #endif - xfp = fopen(filename, "r"); + xfp = fopen(filename, "r" PY_STDIOTEXTMODE); if (xfp == NULL) { /* Search tail of filename in sys.path before giving up */ PyObject *path; @@ -186,7 +186,7 @@ tb_displayline(PyObject *f, char *filename, int lineno, char *name) if (len > 0 && namebuf[len-1] != SEP) namebuf[len++] = SEP; strcpy(namebuf+len, tail); - xfp = fopen(namebuf, "r"); + xfp = fopen(namebuf, "r" PY_STDIOTEXTMODE); if (xfp != NULL) { filename = namebuf; break; @@ -203,7 +203,7 @@ tb_displayline(PyObject *f, char *filename, int lineno, char *name) char* pLastChar = &linebuf[sizeof(linebuf)-2]; do { *pLastChar = '\0'; - if (fgets(linebuf, sizeof linebuf, xfp) == NULL) + if (Py_UniversalNewlineFgets(linebuf, sizeof linebuf, xfp, NULL) == NULL) break; /* fgets read *something*; if it didn't get as far as pLastChar, it must have found a newline |