[Python-checkins] python/dist/src/Python bltinmodule.c,2.250,2.251 errors.c,2.68,2.69 import.c,2.200,2.201 traceback.c,2.37,2.38

jackjansen@sourceforge.net jackjansen@sourceforge.net
Sun, 14 Apr 2002 13:12:43 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv1748/Python

Modified Files:
	bltinmodule.c errors.c import.c traceback.c 
Log Message:
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. 


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.250
retrieving revision 2.251
diff -C2 -d -r2.250 -r2.251
*** bltinmodule.c	3 Apr 2002 22:41:51 -0000	2.250
--- bltinmodule.c	14 Apr 2002 20:12:41 -0000	2.251
***************
*** 595,599 ****
          if (exists) {
  		Py_BEGIN_ALLOW_THREADS
! 		fp = fopen(filename, "r");
  		Py_END_ALLOW_THREADS
  
--- 595,599 ----
          if (exists) {
  		Py_BEGIN_ALLOW_THREADS
! 		fp = fopen(filename, "r" PY_STDIOTEXTMODE);
  		Py_END_ALLOW_THREADS
  

Index: errors.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/errors.c,v
retrieving revision 2.68
retrieving revision 2.69
diff -C2 -d -r2.68 -r2.69
*** errors.c	9 Mar 2002 12:07:51 -0000	2.68
--- errors.c	14 Apr 2002 20:12:41 -0000	2.69
***************
*** 647,651 ****
  	if (filename == NULL || lineno <= 0)
  		return NULL;
! 	fp = fopen(filename, "r");
  	if (fp == NULL)
  		return NULL;
--- 647,651 ----
  	if (filename == NULL || lineno <= 0)
  		return NULL;
! 	fp = fopen(filename, "r" PY_STDIOTEXTMODE);
  	if (fp == NULL)
  		return NULL;
***************
*** 654,658 ****
  		do {
  			*pLastChar = '\0';
! 			if (fgets(linebuf, sizeof linebuf, fp) == NULL)
  				break;
  			/* fgets read *something*; if it didn't get as
--- 654,658 ----
  		do {
  			*pLastChar = '\0';
! 			if (Py_UniversalNewlineFgets(linebuf, sizeof linebuf, fp, NULL) == NULL)
  				break;
  			/* fgets read *something*; if it didn't get as

Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.200
retrieving revision 2.201
diff -C2 -d -r2.200 -r2.201
*** import.c	11 Apr 2002 20:46:23 -0000	2.200
--- import.c	14 Apr 2002 20:12:41 -0000	2.201
***************
*** 82,86 ****
  #ifdef RISCOS
  static const struct filedescr _PyImport_StandardFiletab[] = {
! 	{"/py", "r", PY_SOURCE},
  	{"/pyc", "rb", PY_COMPILED},
  	{0, 0}
--- 82,86 ----
  #ifdef RISCOS
  static const struct filedescr _PyImport_StandardFiletab[] = {
! 	{"/py", "r" PY_STDIOTEXTMODE, PY_SOURCE},
  	{"/pyc", "rb", PY_COMPILED},
  	{0, 0}
***************
*** 88,94 ****
  #else
  static const struct filedescr _PyImport_StandardFiletab[] = {
! 	{".py", "r", PY_SOURCE},
  #ifdef MS_WIN32
! 	{".pyw", "r", PY_SOURCE},
  #endif
  	{".pyc", "rb", PY_COMPILED},
--- 88,94 ----
  #else
  static const struct filedescr _PyImport_StandardFiletab[] = {
! 	{".py", "r" PY_STDIOTEXTMODE, PY_SOURCE},
  #ifdef MS_WIN32
! 	{".pyw", "r" PY_STDIOTEXTMODE, PY_SOURCE},
  #endif
  	{".pyc", "rb", PY_COMPILED},

Index: traceback.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/traceback.c,v
retrieving revision 2.37
retrieving revision 2.38
diff -C2 -d -r2.37 -r2.38
*** traceback.c	29 Mar 2002 03:07:29 -0000	2.37
--- traceback.c	14 Apr 2002 20:12:41 -0000	2.38
***************
*** 156,160 ****
  #define FMT "  File \"%.500s\", line %d, in %.500s\n"
  #endif
! 	xfp = fopen(filename, "r");
  	if (xfp == NULL) {
  		/* Search tail of filename in sys.path before giving up */
--- 156,160 ----
  #define FMT "  File \"%.500s\", line %d, in %.500s\n"
  #endif
! 	xfp = fopen(filename, "r" PY_STDIOTEXTMODE);
  	if (xfp == NULL) {
  		/* Search tail of filename in sys.path before giving up */
***************
*** 187,191 ****
  						namebuf[len++] = SEP;
  					strcpy(namebuf+len, tail);
! 					xfp = fopen(namebuf, "r");
  					if (xfp != NULL) {
  						filename = namebuf;
--- 187,191 ----
  						namebuf[len++] = SEP;
  					strcpy(namebuf+len, tail);
! 					xfp = fopen(namebuf, "r" PY_STDIOTEXTMODE);
  					if (xfp != NULL) {
  						filename = namebuf;
***************
*** 204,208 ****
  		do {
  			*pLastChar = '\0';
! 			if (fgets(linebuf, sizeof linebuf, xfp) == NULL)
  				break;
  			/* fgets read *something*; if it didn't get as
--- 204,208 ----
  		do {
  			*pLastChar = '\0';
! 			if (Py_UniversalNewlineFgets(linebuf, sizeof linebuf, xfp, NULL) == NULL)
  				break;
  			/* fgets read *something*; if it didn't get as