You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Fix precidence between list_if and if_expr in 3.x
This commit is contained in:
@@ -35,6 +35,11 @@ else:
|
|||||||
# Things at the top of this list below with low-value precidence will
|
# Things at the top of this list below with low-value precidence will
|
||||||
# tend to have parenthesis around them. Things at the bottom
|
# tend to have parenthesis around them. Things at the bottom
|
||||||
# of the list will tend not to have parenthesis around them.
|
# of the list will tend not to have parenthesis around them.
|
||||||
|
|
||||||
|
# Note: The values in this table tend to be even value. Inside
|
||||||
|
# various templates we use odd values. Avoiding equal-precident comparisons
|
||||||
|
# avoids ambiguity what to do when the precedence is equal.
|
||||||
|
|
||||||
PRECEDENCE = {
|
PRECEDENCE = {
|
||||||
'list': 0,
|
'list': 0,
|
||||||
'dict': 0,
|
'dict': 0,
|
||||||
|
@@ -23,6 +23,9 @@ def customize_for_version37(self, version):
|
|||||||
#######################
|
#######################
|
||||||
|
|
||||||
PRECEDENCE['attribute37'] = 2
|
PRECEDENCE['attribute37'] = 2
|
||||||
|
PRECEDENCE['ifexp_37a'] = 28
|
||||||
|
PRECEDENCE['ifexp_37b'] = 28
|
||||||
|
|
||||||
TABLE_DIRECT.update({
|
TABLE_DIRECT.update({
|
||||||
'and_not': ( '%c and not %c',
|
'and_not': ( '%c and not %c',
|
||||||
(0, 'expr'), (2, 'expr') ),
|
(0, 'expr'), (2, 'expr') ),
|
||||||
|
@@ -1168,6 +1168,7 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
self.write(' if ')
|
self.write(' if ')
|
||||||
if have_not:
|
if have_not:
|
||||||
self.write('not ')
|
self.write('not ')
|
||||||
|
self.prec = 27
|
||||||
self.preorder(if_node)
|
self.preorder(if_node)
|
||||||
pass
|
pass
|
||||||
self.prec = p
|
self.prec = p
|
||||||
|
Reference in New Issue
Block a user