From: Thomas Hunger Date: Fri, 21 Sep 2007 11:16:39 +0000 (+0200) Subject: Use assert instead of if without else to ensure an object pointer is not NULL. X-Git-Tag: 0.9.6.14~29^2~133 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=257cbde483436c4b0dc614773ba24f8123a7c01d;p=cython.git Use assert instead of if without else to ensure an object pointer is not NULL. gcc complained that a variable might be used uninitialized, which is true. If NULL is passed, all code gets executed with an uninitialized variable which is an error in almost every case. Since python itself never passes NULL, only a real error in other c code could trigger the assert. --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 8f6b729f..12cc26db 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1141,9 +1141,8 @@ class DefNode(FuncDefNode): old_type = arg.hdr_type new_type = arg.type if old_type.is_pyobject: - code.putln("if (likely(%s)) {" % arg.hdr_cname) + code.putln("assert(%s);" % arg.hdr_cname) self.generate_arg_conversion_from_pyobject(arg, code) - code.putln("}") elif new_type.is_pyobject: self.generate_arg_conversion_to_pyobject(arg, code) else: