Commit feee1a22 authored by Robert Bradshaw's avatar Robert Bradshaw

Warning for extern type import size mismatch.

parent ff35cf52
...@@ -445,6 +445,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -445,6 +445,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln(" #define PyInt_AsSsize_t(o) PyInt_AsLong(o)") code.putln(" #define PyInt_AsSsize_t(o) PyInt_AsLong(o)")
code.putln(" #define PyNumber_Index(o) PyNumber_Int(o)") code.putln(" #define PyNumber_Index(o) PyNumber_Int(o)")
code.putln(" #define PyIndex_Check(o) PyNumber_Check(o)") code.putln(" #define PyIndex_Check(o) PyNumber_Check(o)")
code.putln(" #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)")
code.putln("#endif") code.putln("#endif")
code.putln("#if PY_VERSION_HEX < 0x02060000") code.putln("#if PY_VERSION_HEX < 0x02060000")
...@@ -2166,7 +2167,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class ...@@ -2166,7 +2167,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
PyObject *py_module = 0; PyObject *py_module = 0;
PyObject *result = 0; PyObject *result = 0;
PyObject *py_name = 0; PyObject *py_name = 0;
int size_ok; char warning[200];
py_module = __Pyx_ImportModule(module_name); py_module = __Pyx_ImportModule(module_name);
if (!py_module) if (!py_module)
...@@ -2191,13 +2192,13 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class ...@@ -2191,13 +2192,13 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
module_name, class_name); module_name, class_name);
goto bad; goto bad;
} }
if (strict) { if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
size_ok = ((PyTypeObject *)result)->tp_basicsize == size; PyOS_snprintf(warning, sizeof(warning),
} "%s.%s size changed, may indicate binary incompatibility",
else { module_name, class_name);
size_ok = ((PyTypeObject *)result)->tp_basicsize >= size; PyErr_WarnEx(NULL, warning, 0);
} }
if (!size_ok) { else if (((PyTypeObject *)result)->tp_basicsize != size) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"%s.%s has the wrong size, try recompiling", "%s.%s has the wrong size, try recompiling",
module_name, class_name); module_name, class_name);
......
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