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

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
2002年5月30日 10:15:28 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv17379/Python
Modified Files:
	import.c 
Log Message:
Cover a few corners in the 'U' mode integration to make imp work.
get_file() must convert 'U' to "r" PY_STDIOTEXTMODE before calling
fopen().
imp_load_module() must accept 'r' or 'U' or something with '+'.
Also reflow some long lines.
Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.202
retrieving revision 2.203
diff -C2 -d -r2.202 -r2.203
*** import.c	28 May 2002 10:58:19 -0000	2.202
--- import.c	30 May 2002 17:15:25 -0000	2.203
***************
*** 1041,1045 ****
 		for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {
 #if defined(PYOS_OS2)
! 			/* OS/2 limits DLLs to 8 character names (w/o extension)
 			 * so if the name is longer than that and its a
 			 * dynamically loaded module we're going to try,
--- 1041,1046 ----
 		for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {
 #if defined(PYOS_OS2)
! 			/* OS/2 limits DLLs to 8 character names (w/o
! 			 extension)
 			 * so if the name is longer than that and its a
 			 * dynamically loaded module we're going to try,
***************
*** 1048,1054 ****
 			if (strlen(realname) > 8) {
 				/* is this an attempt to load a C extension? */
! 				const struct filedescr *scan = _PyImport_DynLoadFiletab;
 				while (scan->suffix != NULL) {
! 					if (strcmp(scan->suffix, fdp->suffix) == 0)
 						break;
 					else
--- 1049,1056 ----
 			if (strlen(realname) > 8) {
 				/* is this an attempt to load a C extension? */
! 				const struct filedescr *scan;
! 				scan = _PyImport_DynLoadFiletab;
 				while (scan->suffix != NULL) {
! 					if (!strcmp(scan->suffix, fdp->suffix))
 						break;
 					else
***************
*** 1068,1072 ****
 #endif /* !macintosh */
 			filemode = fdp->mode;
! 			if (filemode[0] == 'U') filemode = "r" PY_STDIOTEXTMODE;
 			fp = fopen(buf, filemode);
 			if (fp != NULL) {
--- 1070,1075 ----
 #endif /* !macintosh */
 			filemode = fdp->mode;
! 			if (filemode[0] == 'U') 
! 				filemode = "r" PY_STDIOTEXTMODE;
 			fp = fopen(buf, filemode);
 			if (fp != NULL) {
***************
*** 2297,2300 ****
--- 2300,2305 ----
 	FILE *fp;
 	if (fob == NULL) {
+ 		if (mode[0] == 'U') 
+ 			mode = "r" PY_STDIOTEXTMODE;
 		fp = fopen(pathname, mode);
 		if (fp == NULL)
***************
*** 2404,2411 ****
 			 &suffix, &mode, &type))
 		return NULL;
! 	if (*mode && (*mode != 'r' || strchr(mode, '+') != NULL)) {
! 		PyErr_Format(PyExc_ValueError,
! 			 "invalid file open mode %.200s", mode);
! 		return NULL;
 	}
 	if (fob == Py_None)
--- 2409,2417 ----
 			 &suffix, &mode, &type))
 		return NULL;
! 	if (*mode &&
! 	 !(*mode == 'r' || *mode == 'U' || strchr(mode, '+'))) {
! 			PyErr_Format(PyExc_ValueError,
! 				 "invalid file open mode %.200s", mode);
! 			return NULL;
 	}
 	if (fob == Py_None)

AltStyle によって変換されたページ (->オリジナル) /