mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Fix issues with octals in Python 2 (and possibly 3). Fixes #559.
This commit is contained in:
@@ -52,7 +52,10 @@ name = r'\w+'
|
||||
|
||||
hex_number = r'0[xX][0-9a-fA-F]+'
|
||||
bin_number = r'0[bB][01]+'
|
||||
if is_py3:
|
||||
oct_number = r'0[oO][0-7]+'
|
||||
else:
|
||||
oct_number = '0[0-7]+'
|
||||
dec_number = r'(?:0+|[1-9][0-9]*)'
|
||||
int_number = group(hex_number, bin_number, oct_number, dec_number)
|
||||
exponent = r'[eE][-+]?[0-9]+'
|
||||
|
||||
@@ -664,6 +664,9 @@ class ErrorNode(BaseNode):
|
||||
__slots__ = ()
|
||||
type = 'error_node'
|
||||
|
||||
def nodes_to_execute(self, last_added=False):
|
||||
return []
|
||||
|
||||
|
||||
class ErrorLeaf(LeafWithNewLines):
|
||||
"""
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user