diff options
| -rw-r--r-- | Cython/Compiler/ModuleNode.py | 9 | ||||
| -rw-r--r-- | Cython/Utility/ModuleSetupCode.c | 8 |
2 files changed, 9 insertions, 8 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 251581715..c837c8e3f 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1296,14 +1296,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("if (p->__weakref__) PyObject_ClearWeakRefs(o);") for entry in cpp_class_attrs: - split_cname = entry.type.cname.split('::') - destructor_name = split_cname.pop() - # Make sure the namespace delimiter was not in a template arg. - while destructor_name.count('<') != destructor_name.count('>'): - destructor_name = split_cname.pop() + '::' + destructor_name - destructor_name = destructor_name.split('<', 1)[0] - code.putln("p->%s.%s::~%s();" % ( - entry.cname, entry.type.declaration_code(""), destructor_name)) + code.putln("__Pyx_call_destructor(&p->%s);" % entry.cname) for entry in py_attrs: code.put_xdecref_clear("p->%s" % entry.cname, entry.type, nanny=False, diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c index 6d9ac1a08..fc8a63ffa 100644 --- a/Cython/Utility/ModuleSetupCode.c +++ b/Cython/Utility/ModuleSetupCode.c @@ -336,6 +336,14 @@ static CYTHON_INLINE float __PYX_NAN() { } #endif +// Work around clang bug http://stackoverflow.com/questions/21847816/c-invoke-nested-template-class-destructor +#ifdef __cplusplus +template<typename T> +void __Pyx_call_destructor(T* x) { + x->~T(); +} +#endif + /////////////// UtilityFunctionPredeclarations.proto /////////////// /* unused attribute */ |
