fix compatibility with python<=2.4
authorHaoyu Bai <baihaoyu@gmail.com>
Fri, 1 Apr 2011 15:53:46 +0000 (23:53 +0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sat, 16 Apr 2011 07:36:29 +0000 (00:36 -0700)
Cython/Compiler/Parsing.py

index d72aeaa11fc53acff7f6b79ef54492624b465c01..910e62a950e5b0a7b0e57ea2a63a47f7a0e6ca3b 100644 (file)
@@ -1190,7 +1190,10 @@ def p_raise_statement(s):
 
 def p_import_statement(s):
     # will do absolute import in Py3 and try both relative and absolute in Py2.
-    level = 0 if s.context.language_level >= 3 else -1
+    if s.context.language_level >= 3:
+        level = 0
+    else:
+        level = -1
     # s.sy in ('import', 'cimport')
     pos = s.position()
     kind = s.sy
@@ -1235,7 +1238,10 @@ def p_from_import_statement(s, first_statement = 0):
             s.next()
     else:
         # will do absolute import in Py3 and try both relative and absolute in Py2.
-        level = 0 if s.context.language_level >= 3 else -1
+        if s.context.language_level >= 3:
+            level = 0
+        else:
+            level = -1
 
     if level > 0 and s.sy == 'cimport':
         s.error("Relative cimport is not supported yet")