From 3bd0078fc8c05655df99fdce03a14fe656efecbf Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Thu, 14 May 2009 01:16:59 -0700 Subject: [PATCH] Minor complex number fixes --- Cython/Compiler/ExprNodes.py | 9 ++++++--- tests/errors/nogil.pyx | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 7cd13af7..5ae051bf 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1048,8 +1048,8 @@ class ImagNode(AtomicNewTempExprNode): # when coercing to a Python type. if dst_type.is_pyobject: self.is_temp = 1 - self.gil_check(env) self.type = PyrexTypes.py_object_type + self.gil_check(env) # We still need to perform normal coerce_to processing on the # result, because we might be coercing to an extension type, # in which case a type test node will be needed. @@ -4183,6 +4183,8 @@ class BinopNode(NewTempExprNode): class NumBinopNode(BinopNode): # Binary operation taking numeric arguments. + infix = True + def analyse_c_operation(self, env): type1 = self.operand1.type type2 = self.operand2.type @@ -4190,7 +4192,8 @@ class NumBinopNode(BinopNode): if not self.type: self.type_error() return - self.infix = not self.type.is_complex or env.directives['c99_complex'] + if self.type.is_complex and not env.directives['c99_complex']: + self.infix = False if not self.infix: self.operand1 = self.operand1.coerce_to(self.type, env) self.operand2 = self.operand2.coerce_to(self.type, env) @@ -4351,7 +4354,7 @@ class DivNode(NumBinopNode): code.putln('PyErr_Format(PyExc_OverflowError, "value too large to perform division");') code.putln(code.error_goto(self.pos)) code.putln("}") - if code.globalstate.directives['cdivision_warnings'] and self.operand != '/': + if code.globalstate.directives['cdivision_warnings'] and self.operator != '/': code.globalstate.use_utility_code(cdivision_warning_utility_code) code.putln("if ((%s < 0) ^ (%s < 0)) {" % ( self.operand1.result(), diff --git a/tests/errors/nogil.pyx b/tests/errors/nogil.pyx index 10a9fe7e..570aeb14 100644 --- a/tests/errors/nogil.pyx +++ b/tests/errors/nogil.pyx @@ -25,7 +25,7 @@ cdef object m(): i = 42 obj = None 17L - 7j + 7j help `"Hello"` import fred @@ -85,7 +85,7 @@ _ERRORS = u""" 15: 5: Calling gil-requiring function without gil 24: 9: Calling gil-requiring function without gil 26:12: Assignment of Python object not allowed without gil -28: 8: Constructing complex number not allowed without gil +28:16: Constructing complex number not allowed without gil 29:12: Accessing Python global or builtin not allowed without gil 30: 8: Backquote expression not allowed without gil 31:15: Python import not allowed without gil -- 2.26.2