Mercurial > cpython-lru_cache-weakref
diff Python/dynload_mac.c @ 11756:6367d829f36b legacy-trunk
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).
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 14 Feb 2000 17:58:25 +0000 |
| parents | 528559a0b2f2 |
| children | 3500c4350f62 |
line wrap: on
line diff
--- a/Python/dynload_mac.c Mon Feb 14 14:14:29 2000 +0000 +++ b/Python/dynload_mac.c Mon Feb 14 17:58:25 2000 +0000 @@ -114,6 +114,18 @@ 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,
