You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +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
|
||||
# tend to have parenthesis around them. Things at the bottom
|
||||
# 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 = {
|
||||
'list': 0,
|
||||
'dict': 0,
|
||||
|
@@ -22,7 +22,10 @@ def customize_for_version37(self, version):
|
||||
# Python 3.7+ changes
|
||||
#######################
|
||||
|
||||
PRECEDENCE['attribute37'] = 2
|
||||
PRECEDENCE['attribute37'] = 2
|
||||
PRECEDENCE['ifexp_37a'] = 28
|
||||
PRECEDENCE['ifexp_37b'] = 28
|
||||
|
||||
TABLE_DIRECT.update({
|
||||
'and_not': ( '%c and not %c',
|
||||
(0, 'expr'), (2, 'expr') ),
|
||||
|
@@ -1168,6 +1168,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.write(' if ')
|
||||
if have_not:
|
||||
self.write('not ')
|
||||
self.prec = 27
|
||||
self.preorder(if_node)
|
||||
pass
|
||||
self.prec = p
|
||||
|
Reference in New Issue
Block a user