Minor complex number fixes
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 14 May 2009 08:16:59 +0000 (01:16 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 14 May 2009 08:16:59 +0000 (01:16 -0700)
Cython/Compiler/ExprNodes.py
tests/errors/nogil.pyx

index 7cd13af7f8b0e8b36a06f14a44d7f92a8d60c489..5ae051bf6a752a66d6b495a277131577eb0043c2 100644 (file)
@@ -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(),
index 10a9fe7e72b4bcf607926928d8532485f77dbaac..570aeb1425f226e3ed8d8b5b85371064b27be23f 100644 (file)
@@ -25,7 +25,7 @@ cdef object m():
         i = 42
         obj = None
         17L
-        7j
+        <object>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