[Python-checkins] CVS: python/dist/src/Python dynload_mac.c,2.2,2.3

Guido van Rossum guido@cnri.reston.va.us
Mon, 14 Feb 2000 12:58:28 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Python
In directory eric:/projects/python/develop/guido/src/Python

Modified Files:
	dynload_mac.c 
Log Message:
Patch by Jack Jansen:

If we attempt to import a dynamic module in a newer (or older) version
of Python give an error message tailored to the situation (Python too
new/old).


Index: dynload_mac.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/dynload_mac.c,v
retrieving revision 2.2
retrieving revision 2.3
diff -C2 -r2.2 -r2.3
*** dynload_mac.c	1999/12/22 14:09:35	2.2
--- dynload_mac.c	2000/02/14 17:58:25	2.3
***************
*** 115,118 ****
--- 115,130 ----
  			      kLoadCFrag, &connID, &mainAddr,
  			      errMessage);
+ 	if ( err == cfragImportTooOldErr || err == cfragImportTooNewErr ) {
+ 		/*
+ 		** Special-case code: if PythonCore is too old or too new this means
+ 		** the dynamic module was meant for a different Python.
+ 		*/
+ 		if (errMessage[0] == 10 && strncmp((char *)errMessage+1, "PythonCore", 10) == 0 ) {
+ 			sprintf(buf, "Dynamic module was built for %s version of MacPython",
+ 				(err == cfragImportTooOldErr ? "a newer" : "an older"));
+ 			PyErr_SetString(PyExc_ImportError, buf);
+ 			return NULL;
+ 		}
+ 	}
  	if ( err ) {
  		sprintf(buf, "%.*s: %.200s",