diff Python/errors.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 f4487350c537
children 8142f8d668a0
line wrap: on
line diff
--- a/Python/errors.c	Sun Apr 14 10:30:51 2002 +0000
+++ b/Python/errors.c	Sun Apr 14 20:12:41 2002 +0000
@@ -646,14 +646,14 @@
 
 	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