Fix issues with octals in Python 2 (and possibly 3). Fixes #559.

This commit is contained in:
Dave Halter
2016-07-17 22:36:26 +02:00
parent 68ff520cf8
commit 2563746810
3 changed files with 25 additions and 1 deletions

View File

@@ -218,3 +218,21 @@ def test_backslash_dos_style():
def test_started_lambda_stmt():
p = ParserWithRecovery(load_grammar(), u'lambda a, b: a i')
assert p.get_parsed_node().children[0].type == 'error_node'
def test_python2_octal():
parser = ParserWithRecovery(load_grammar(), u'0660')
first = parser.get_parsed_node().children[0]
if is_py3:
assert first.type == 'error_node'
else:
assert first.children[0].type == 'number'
def test_python3_octal():
parser = ParserWithRecovery(load_grammar(), u'0o660')
module = parser.get_parsed_node()
if is_py3:
assert module.children[0].children[0].type == 'number'
else:
assert module.children[0].type == 'error_node'