diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index f13d990e..4ffd34c0 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -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, diff --git a/uncompyle6/semantics/customize37.py b/uncompyle6/semantics/customize37.py index 13699c52..eb46ddf6 100644 --- a/uncompyle6/semantics/customize37.py +++ b/uncompyle6/semantics/customize37.py @@ -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') ), diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 1a49cfbf..7a59a72c 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -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