Commit 4a598d1c authored by Lisandro Dalcin's avatar Lisandro Dalcin

even better __Pyx_check_binary_version()

parent 90120314
...@@ -2858,18 +2858,15 @@ check_binary_version_utility_code = UtilityCode(proto=""" ...@@ -2858,18 +2858,15 @@ check_binary_version_utility_code = UtilityCode(proto="""
static int __Pyx_check_binary_version(void); static int __Pyx_check_binary_version(void);
""", impl=""" """, impl="""
static int __Pyx_check_binary_version(void) { static int __Pyx_check_binary_version(void) {
long version_hex, major_version, minor_version; char ctversion[4], rtversion[4];
PyObject *sys_hexversion = PySys_GetObject((char*)"hexversion"); PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
if (sys_hexversion == NULL) return -1; PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
version_hex = PyInt_AsLong(sys_hexversion); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
if (version_hex == -1 && PyErr_Occurred()) return -1;
major_version = ((unsigned long)version_hex >> 24);
minor_version = ((unsigned long)version_hex >> 16) & 0x00FF;
if (!(major_version == PY_MAJOR_VERSION && minor_version == PY_MINOR_VERSION)) {
char message[200]; char message[200];
PyOS_snprintf(message, sizeof(message), PyOS_snprintf(message, sizeof(message),
"compiletime version (%d, %d) of module '%.100s' does not match runtime version (%d, %d).", "compiletime version %s of module '%.100s' "
PY_MAJOR_VERSION, PY_MINOR_VERSION, __Pyx_MODULE_NAME, (int)major_version, (int)minor_version); "does not match runtime version %s",
ctversion, __Pyx_MODULE_NAME, rtversion);
#if PY_VERSION_HEX < 0x02050000 #if PY_VERSION_HEX < 0x02050000
return PyErr_Warn(NULL, message); return PyErr_Warn(NULL, message);
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment