Commit 4fc682ab authored by Robert Bradshaw's avatar Robert Bradshaw

Complile/runtime version mismatch warning.

parent c71adccb
...@@ -1745,6 +1745,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1745,6 +1745,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("{") code.putln("{")
tempdecl_code = code.insertion_point() tempdecl_code = code.insertion_point()
env.use_utility_code(check_binary_version_utility_code)
code.putln("__Pyx_check_binary_version();")
code.putln("#if CYTHON_REFNANNY") code.putln("#if CYTHON_REFNANNY")
code.putln("void* __pyx_refnanny = NULL;") code.putln("void* __pyx_refnanny = NULL;")
code.putln("__Pyx_RefNanny = __Pyx_RefNannyImportAPI(\"refnanny\");") code.putln("__Pyx_RefNanny = __Pyx_RefNannyImportAPI(\"refnanny\");")
...@@ -2850,3 +2853,40 @@ packed_struct_utility_code = UtilityCode(proto=""" ...@@ -2850,3 +2853,40 @@ packed_struct_utility_code = UtilityCode(proto="""
#define __Pyx_PACKED #define __Pyx_PACKED
#endif #endif
""", impl="", proto_block='utility_code_proto_before_types') """, impl="", proto_block='utility_code_proto_before_types')
check_binary_version_utility_code = UtilityCode(proto="""
static int __Pyx_check_binary_version(void);
""", impl="""
static int __Pyx_check_binary_version(void) {
int res = -1;
PyObject *major_info = NULL;
PyObject *minor_info = NULL;
PyObject *version_info = PySys_GetObject("version_info");
if (version_info == NULL) goto bad;
major_info = PySequence_GetItem(version_info, 0);
if (major_info == NULL || !PyInt_CheckExact(major_info)) goto bad;
minor_info = PySequence_GetItem(version_info, 1);
if (minor_info == NULL || !PyInt_CheckExact(minor_info)) goto bad;
if (PyInt_AsLong(major_info) == PY_MAJOR_VERSION && PyInt_AsLong(minor_info) == PY_MINOR_VERSION) {
res = 0;
} else {
char warning[200];
PyOS_snprintf(warning, sizeof(warning),
"compiletime version (%d, %d) of module %s does not match runtime version (%ld, %ld)",
PY_MAJOR_VERSION, PY_MINOR_VERSION,
__Pyx_MODULE_NAME,
PyInt_AsLong(major_info), PyInt_AsLong(minor_info));
#if PY_VERSION_HEX < 0x02050000
PyErr_Warn(NULL, warning);
#else
PyErr_WarnEx(NULL, warning, 0);
#endif
res = 1;
}
bad:
Py_XDECREF(version_info);
Py_XDECREF(major_info);
Py_XDECREF(minor_info);
return res;
}
""")
...@@ -45,7 +45,8 @@ init_local_none = 1 ...@@ -45,7 +45,8 @@ init_local_none = 1
# Whether or not to embed the Python interpreter, for use in making a # Whether or not to embed the Python interpreter, for use in making a
# standalone executable or calling from external libraries. # standalone executable or calling from external libraries.
# This will provide a method which simply executes the body of this module. # This will provide a method which initalizes the interpreter and
# executes the body of this module.
embed = None embed = None
# Disables function redefinition, allowing all functions to be declared at # Disables function redefinition, allowing all functions to be declared at
......
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