From d40333a24b41507455a949fe3d5305c9286c7233 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 9 Aug 2013 10:47:02 +0200 Subject: [PATCH] fix code generated for __dealloc__() and __releasebuffer__() to call WriteUnraisable() on exceptions instead of building a useless traceback --- Cython/Compiler/ModuleNode.py | 1 - Cython/Compiler/Nodes.py | 2 +- Cython/Compiler/TypeSlots.py | 5 ++++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index a5cc35f..a482042 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1293,7 +1293,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("PyErr_Fetch(&etype, &eval, &etb);") code.putln("++Py_REFCNT(o);") code.putln("%s(o);" % entry.func_cname) - code.putln("if (PyErr_Occurred()) PyErr_WriteUnraisable(o);") code.putln("--Py_REFCNT(o);") code.putln("PyErr_Restore(etype, eval, etb);") code.putln("}") diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index fc72b89..852d628 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2788,7 +2788,7 @@ class DefNode(FuncDefNode): return self.entry.signature.error_value def caller_will_check_exceptions(self): - return 1 + return self.entry.signature.exception_check def generate_function_definitions(self, env, code): if self.defaults_getter: diff --git a/Cython/Compiler/TypeSlots.py b/Cython/Compiler/TypeSlots.py index eca0e37..118c704 100644 --- a/Cython/Compiler/TypeSlots.py +++ b/Cython/Compiler/TypeSlots.py @@ -93,6 +93,7 @@ class Signature(object): self.fixed_arg_format = arg_format self.ret_format = ret_format self.error_value = self.error_value_map.get(ret_format, None) + self.exception_check = self.error_value is not None self.is_staticmethod = False def num_fixed_args(self): @@ -135,7 +136,9 @@ class Signature(object): else: ret_type = self.return_type() exc_value = self.exception_value() - return PyrexTypes.CFuncType(ret_type, args, exception_value = exc_value) + return PyrexTypes.CFuncType( + ret_type, args, exception_value=exc_value, + exception_check=self.exception_check) def method_flags(self): if self.ret_format == "O": -- 2.7.4