Commit cf7ae767 authored by Haoyu Bai's avatar Haoyu Bai Committed by Robert Bradshaw

fix compatibility with python<=2.4

parent 599c3405
...@@ -1190,7 +1190,10 @@ def p_raise_statement(s): ...@@ -1190,7 +1190,10 @@ def p_raise_statement(s):
def p_import_statement(s): def p_import_statement(s):
# will do absolute import in Py3 and try both relative and absolute in Py2. # 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') # s.sy in ('import', 'cimport')
pos = s.position() pos = s.position()
kind = s.sy kind = s.sy
...@@ -1235,7 +1238,10 @@ def p_from_import_statement(s, first_statement = 0): ...@@ -1235,7 +1238,10 @@ def p_from_import_statement(s, first_statement = 0):
s.next() s.next()
else: else:
# will do absolute import in Py3 and try both relative and absolute in Py2. # 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': if level > 0 and s.sy == 'cimport':
s.error("Relative cimport is not supported yet") s.error("Relative cimport is not supported yet")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment