Commit 61a825b7 authored by Vitja Makarov's avatar Vitja Makarov

Merge remote branch 'upstream/master'

parents 6d2165ee 4fc682ab
...@@ -1744,6 +1744,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1744,6 +1744,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("#endif") code.putln("#endif")
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;")
...@@ -2852,3 +2855,40 @@ packed_struct_utility_code = UtilityCode(proto=""" ...@@ -2852,3 +2855,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;
}
""")
...@@ -1057,6 +1057,8 @@ class CppClassNode(CStructOrUnionDefNode): ...@@ -1057,6 +1057,8 @@ class CppClassNode(CStructOrUnionDefNode):
self.entry = env.declare_cpp_class( self.entry = env.declare_cpp_class(
self.name, scope, self.pos, self.name, scope, self.pos,
self.cname, base_class_types, visibility = self.visibility, templates = template_types) self.cname, base_class_types, visibility = self.visibility, templates = template_types)
if self.entry is None:
return
self.entry.is_cpp_class = 1 self.entry.is_cpp_class = 1
if self.attributes is not None: if self.attributes is not None:
if self.in_pxd and not env.in_cinclude: if self.in_pxd and not env.in_cinclude:
......
...@@ -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
......
...@@ -449,7 +449,8 @@ class Scope(object): ...@@ -449,7 +449,8 @@ class Scope(object):
visibility = visibility, defining = scope is not None) visibility = visibility, defining = scope is not None)
else: else:
if not (entry.is_type and entry.type.is_cpp_class): if not (entry.is_type and entry.type.is_cpp_class):
warning(pos, "'%s' redeclared " % name, 0) error(pos, "'%s' redeclared " % name)
return None
elif scope and entry.type.scope: elif scope and entry.type.scope:
warning(pos, "'%s' already defined (ignoring second definition)" % name, 0) warning(pos, "'%s' already defined (ignoring second definition)" % name, 0)
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