[Python-checkins] python/dist/src/Python import.c,2.201,2.202

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Tue, 28 May 2002 03:58:22 -0700


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

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


Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.201
retrieving revision 2.202
diff -C2 -d -r2.201 -r2.202
*** import.c	14 Apr 2002 20:12:41 -0000	2.201
--- import.c	28 May 2002 10:58:19 -0000	2.202
***************
*** 82,86 ****
  #ifdef RISCOS
  static const struct filedescr _PyImport_StandardFiletab[] = {
! 	{"/py", "r" PY_STDIOTEXTMODE, PY_SOURCE},
  	{"/pyc", "rb", PY_COMPILED},
  	{0, 0}
--- 82,86 ----
  #ifdef RISCOS
  static const struct filedescr _PyImport_StandardFiletab[] = {
! 	{"/py", "U", PY_SOURCE},
  	{"/pyc", "rb", PY_COMPILED},
  	{0, 0}
***************
*** 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},
--- 88,94 ----
  #else
  static const struct filedescr _PyImport_StandardFiletab[] = {
! 	{".py", "U", PY_SOURCE},
  #ifdef MS_WIN32
! 	{".pyw", "U", PY_SOURCE},
  #endif
  	{".pyc", "rb", PY_COMPILED},
***************
*** 893,896 ****
--- 893,897 ----
  	size_t len, namelen;
  	struct filedescr *fdp = NULL;
+ 	char *filemode;
  	FILE *fp = NULL;
  #ifndef RISCOS
***************
*** 1066,1070 ****
  				PySys_WriteStderr("# trying %s\n", buf);
  #endif /* !macintosh */
! 			fp = fopen(buf, fdp->mode);
  			if (fp != NULL) {
  				if (case_ok(buf, len, namelen, name))
--- 1067,1073 ----
  				PySys_WriteStderr("# trying %s\n", buf);
  #endif /* !macintosh */
! 			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))