From 6f112ec5b2daf8be6b8882119e9fdb50e6440340 Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 3 Mar 2022 21:05:47 -0500 Subject: [PATCH] Ensure no parens on subscript slice --- uncompyle6/semantics/consts.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index a859447f..4bf835a8 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -45,6 +45,9 @@ maxint = sys.maxsize # say to 100, to make sure we avoid additional prenthesis in # call((.. op ..)). +NO_PARENTHESIS_EVER = 100 + +# fmt: off PRECEDENCE = { "named_expr": 40, # := "yield": 38, # Needs to be below named_expr @@ -240,8 +243,19 @@ TABLE_DIRECT = { (0, "expr", PRECEDENCE["subscript"]), (1, "expr"), ), - "subscript": ("%p[%c]", (0, "expr", PRECEDENCE["subscript"]), (1, "expr")), - "subscript2": ("%p[%c]", (0, "expr", PRECEDENCE["subscript"]), (1, "expr")), + + "subscript": ( + "%p[%p]", + (0, "expr", PRECEDENCE["subscript"]), + (1, "expr", NO_PARENTHESIS_EVER) + ), + + "subscript2": ( + "%p[%p]", + (0, "expr", PRECEDENCE["subscript"]), + (1, "expr", NO_PARENTHESIS_EVER) + ), + "store_subscript": ("%p[%c]", (0, "expr", PRECEDENCE["subscript"]), (1, "expr")), "STORE_FAST": ("%{pattr}",), "STORE_NAME": ("%{pattr}",),