Mercurial > cpython-lru_cache-weakref
diff Python/traceback.c @ 23029:8291473fde3e legacy-trunk
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.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Sun, 14 Apr 2002 20:12:41 +0000 |
| parents | 2288c724fe2b |
| children | cf5928fab108 |
line wrap: on
line diff
--- a/Python/traceback.c Sun Apr 14 10:30:51 2002 +0000 +++ b/Python/traceback.c Sun Apr 14 20:12:41 2002 +0000 @@ -155,7 +155,7 @@ /* 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 @@ 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 @@ 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
