[Python-checkins] CVS: python/dist/src/Python importdl.c,2.68,2.69

Guido van Rossum gvanrossum@users.sourceforge.net
2001年10月16日 13:07:36 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv11552
Modified Files:
	importdl.c 
Log Message:
SF patch #471839: Bug when extensions import extensions (Shane Hathaway)
 When an extension imports another extension in its 
 initXXX() function, the variable _Py_PackageContext is 
 prematurely reset to NULL. If the outer extension then 
 calls Py_InitModule(), the extension is installed in 
 sys.modules without its package name. The 
 manifestation of this bug is a "SystemError: 
 _PyImport_FixupExtension: module <package>.<extension> 
 not loaded". 
 To fix this, importdl.c just needs to retain the old 
 value of _Py_PackageContext and restore it after the 
 initXXX() method is called. The attached patch does this. 
 This patch applies to Python 2.1.1 and the current CVS.
Index: importdl.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/importdl.c,v
retrieving revision 2.68
retrieving revision 2.69
diff -C2 -d -r2.68 -r2.69
*** importdl.c	2000年09月01日 23:29:28	2.68
--- importdl.c	2001年10月16日 20:07:34	2.69
***************
*** 23,27 ****
 {
 	PyObject *m, *d, *s;
! 	char *lastdot, *shortname, *packagecontext;
 	dl_funcptr p;
 
--- 23,27 ----
 {
 	PyObject *m, *d, *s;
! 	char *lastdot, *shortname, *packagecontext, *oldcontext;
 	dl_funcptr p;
 
***************
*** 49,55 ****
 		return NULL;
 	}
 	_Py_PackageContext = packagecontext;
 	(*p)();
! 	_Py_PackageContext = NULL;
 	if (PyErr_Occurred())
 		return NULL;
--- 49,56 ----
 		return NULL;
 	}
+ oldcontext = _Py_PackageContext;
 	_Py_PackageContext = packagecontext;
 	(*p)();
! 	_Py_PackageContext = oldcontext;
 	if (PyErr_Occurred())
 		return NULL;

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