summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-02-14 17:58:25 (GMT)
committerGuido van Rossum <guido@python.org>2000-02-14 17:58:25 (GMT)
commite817acd957c8be17caa6711ddd00e44aa793b355 (patch)
tree76050b00b87cef6897a265bd42bf5fc19782e58a /Python
parenta50581228ebf9e9f1008022bdef735fb4c722705 (diff)
downloadcpython-e817acd957c8be17caa6711ddd00e44aa793b355.zip
cpython-e817acd957c8be17caa6711ddd00e44aa793b355.tar.gz
cpython-e817acd957c8be17caa6711ddd00e44aa793b355.tar.bz2
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).
Diffstat (limited to 'Python')
-rw-r--r--Python/dynload_mac.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Python/dynload_mac.c b/Python/dynload_mac.c
index 58c57d5..8846803 100644
--- a/Python/dynload_mac.c
+++ b/Python/dynload_mac.c
@@ -114,6 +114,18 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
err = GetDiskFragment(&libspec, 0, 0, fragname,
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",
errMessage[0], errMessage+1,