You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
back off of build_slice{2,3} ->slice{2,3}
There is another slice rule that interferes with this.
This commit is contained in:
@@ -317,15 +317,15 @@ class Python2Parser(PythonParser):
|
||||
slice_num = token.attr
|
||||
if slice_num == 2:
|
||||
self.add_unique_rules([
|
||||
'expr ::= slice2',
|
||||
'slice2 ::= expr expr BUILD_SLICE_2'
|
||||
'expr ::= build_slice2',
|
||||
'build_slice2 ::= expr expr BUILD_SLICE_2'
|
||||
], customize)
|
||||
else:
|
||||
assert slice_num == 3, ("BUILD_SLICE value must be 2 or 3; is %s" %
|
||||
slice_num)
|
||||
self.add_unique_rules([
|
||||
'expr ::= slice3',
|
||||
'slice3 ::= expr expr expr BUILD_SLICE_3',
|
||||
'expr ::= build_slice3',
|
||||
'build_slice3 ::= expr expr expr BUILD_SLICE_3',
|
||||
], customize)
|
||||
continue
|
||||
elif opname_base in ('CALL_FUNCTION', 'CALL_FUNCTION_VAR',
|
||||
|
@@ -741,14 +741,14 @@ class Python3Parser(PythonParser):
|
||||
elif opname_base == 'BUILD_SLICE':
|
||||
if token.attr == 2:
|
||||
self.add_unique_rules([
|
||||
'expr ::= slice2',
|
||||
'slice2 ::= expr expr BUILD_SLICE_2'
|
||||
'expr ::= build_slice2',
|
||||
'build_slice2 ::= expr expr BUILD_SLICE_2'
|
||||
], customize)
|
||||
else:
|
||||
assert token.attr == 3, "BUILD_SLICE value must be 2 or 3; is %s" % v
|
||||
self.add_unique_rules([
|
||||
'expr ::= slice3',
|
||||
'slice3 ::= expr expr expr BUILD_SLICE_3',
|
||||
'expr ::= build_slice3',
|
||||
'build_slice3 ::= expr expr expr BUILD_SLICE_3',
|
||||
], customize)
|
||||
elif opname_base == 'CALL_METHOD':
|
||||
# PyPy only - DRY with parse2
|
||||
|
@@ -714,7 +714,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
assert False, "dunno about this python version"
|
||||
self.prune() # stop recursing
|
||||
|
||||
def n_slice3(self, node):
|
||||
def n_build_slice3(self, node):
|
||||
p = self.prec
|
||||
self.prec = 100
|
||||
if not node[0].isNone():
|
||||
@@ -728,7 +728,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.prec = p
|
||||
self.prune() # stop recursing
|
||||
|
||||
def n_slice2(self, node):
|
||||
def n_build_slice2(self, node):
|
||||
p = self.prec
|
||||
self.prec = 100
|
||||
if not node[0].isNone():
|
||||
@@ -1744,7 +1744,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
# if a tuple item is some sort of slice.
|
||||
no_parens = False
|
||||
for n in node:
|
||||
if n == 'expr' and n[0].kind.startswith('slice'):
|
||||
if n == 'expr' and n[0].kind.startswith('build_slice'):
|
||||
no_parens = True
|
||||
break
|
||||
pass
|
||||
|
Reference in New Issue
Block a user