From 600688a65d72627b703ff6145be6681426f9ab64 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 17 Sep 2022 10:13:27 -0400 Subject: [PATCH] Sync with decompyle3 --- admin-tools/pyenv-newest-versions | 2 +- test/bytecode_3.6_run/10_fstring.pyc | Bin 1526 -> 2203 bytes test/simple_source/bug36/10_fstring.py | 24 +++++++++--- uncompyle6/semantics/customize37.py | 49 +++++++++++++++++++------ 4 files changed, 58 insertions(+), 17 deletions(-) diff --git a/admin-tools/pyenv-newest-versions b/admin-tools/pyenv-newest-versions index b6dd3491..f2c5ebcc 100644 --- a/admin-tools/pyenv-newest-versions +++ b/admin-tools/pyenv-newest-versions @@ -5,4 +5,4 @@ if [[ $0 == ${BASH_SOURCE[0]} ]] ; then echo "This script should be *sourced* rather than run directly through bash" exit 1 fi -export PYVERSIONS='3.6.15 pypy3.6-7.3.1 3.7.13 pypy3.8-7.3.9 pyston-2.3.3 3.8.13' +export PYVERSIONS='3.6.15 pypy3.6-7.3.1 3.7.14 pypy3.8-7.3.9 pyston-2.3.3 3.8.14' diff --git a/test/bytecode_3.6_run/10_fstring.pyc b/test/bytecode_3.6_run/10_fstring.pyc index b54bc4915c6d5d47f46d0f73b50da8cb08d7d842..c3ae23255cfd7e886ed86bb7ebae1caba60a6e58 100644 GIT binary patch literal 2203 zcmb^yU2oJzaChyybIe^Xgph;~z)1?>3LFGlDj|rFpj4`=NEH&Lt5%ld**knVcChat zG2!W=(uY2@&ryCrpZi<-vafy0U&vEu)=5aBK6XztJD%P7o}IhbXt>}1eKq{6!Pr0S z*s3G_7$JYj83QI6aLGYP0T$TXOj=NZYL^QpZCO$F4uhJi?1)`UR>4tK{2l?fhrA(2 z`pj-cI#7oOjCL(K0!`_vGiqeWVQj}%?i54b+0%R&-xa+&oEvgAGR0uR+&T}FaYHs> zN{+&`Y{CWA=#BNxs!?NSX4g_pyn7MvHeptd!zFnRF3SnH0v>vO9_C;k_sJt)rtq}7 zSy$7rFyx&5z>-OusSB^&-+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!b^w)a+3j9sv6 z55;VgRqw%TqnYpG)(5#h1putnQD9DAs zU?v}L%b?w8Ka8%zAYg_ngm2BSZp3j7Z7eKmsQs;=lo}^W}P5bYh;LKiHURYVZzxIH}lBI;2j9`kuofQ0JS1t8%S)03i z`x*{3oGAK9nHmq@SPD@p diff --git a/test/simple_source/bug36/10_fstring.py b/test/simple_source/bug36/10_fstring.py index 876f15e9..52f79481 100644 --- a/test/simple_source/bug36/10_fstring.py +++ b/test/simple_source/bug36/10_fstring.py @@ -59,9 +59,9 @@ log_rounds = 5 assert "05$" == f"{log_rounds:02d}$" -def testit(a, b, l): - # print(l) - return l +def testit(a, b, ll): + # print(ll) + return ll # The call below shows the need for BUILD_STRING to count expr arguments. @@ -102,11 +102,11 @@ assert f"x={x*y:{width}}" == "x=foofoo " # equivalent thing. For compatiblity with older Python we'll use "%" # instead of a format string def f(): - f"""Not a docstring""" + f"""Not a docstring""" # noqa def g(): - """Not a docstring""" f"" + """Not a docstring""" f"" # noqa assert f.__doc__ is None @@ -129,3 +129,17 @@ assert f'{f"{0}"*3}' == "000" # The former, {{ confuses the format strings so dictionary/set comprehensions # don't work. assert f"expr={ {x: y for x, y in [(1, 2), ]}}" == "expr={1: 2}" + + +class Line: + def __init__(self, x, y): + self.x = x + self.y = y + + # From 3.7 test_typing.py + def __str__(self): + return f"{self.x} -> {self.y}" + + +line = Line(1, 2) +assert str(line) == "1 -> 2" diff --git a/uncompyle6/semantics/customize37.py b/uncompyle6/semantics/customize37.py index fe4c0c4b..b2680432 100644 --- a/uncompyle6/semantics/customize37.py +++ b/uncompyle6/semantics/customize37.py @@ -94,8 +94,7 @@ def customize_for_version37(self, version): # need parenthesis. # Note there are async dictionary expressions are like await expr's # the below is just the default fersion - "await_expr": ("await %p", (0, PRECEDENCE["await_expr"]-1)), - + "await_expr": ("await %p", (0, PRECEDENCE["await_expr"] - 1)), "await_stmt": ("%|%c\n", 0), "c_async_with_stmt": ("%|async with %c:\n%+%c%-", (0, "expr"), 3), "call_ex": ("%c(%p)", (0, "expr"), (1, 100)), @@ -156,7 +155,10 @@ def customize_for_version37(self, version): (2, "import_from_attr37"), (3, "store"), ), - "import_one": ("%c", (0, "importlists"),), + "import_one": ( + "%c", + (0, "importlists"), + ), "importattr37": ("%c", (0, "IMPORT_NAME_ATTR")), "import_from_attr37": ( "%c import %c", @@ -165,12 +167,9 @@ def customize_for_version37(self, version): ), "list_afor": ( " async for %[1]{%c} in %c%[1]{%c}", - (1, "store"), (0, "get_aiter"), (3, "list_iter"), - ), - - "list_afor": ( - " async for %[1]{%c} in %c%[1]{%c}", - (1, "store"), (0, "get_aiter"), (3, "list_iter"), + (1, "store"), + (0, "get_aiter"), + (3, "list_iter"), ), "list_if37": (" if %p%c", (0, 27), 1), @@ -408,12 +407,17 @@ def customize_for_version37(self, version): self.n_call = n_call def n_compare_chained(node): - if node[0] == "compare_chained37": + if node[0] in ( + "c_compare_chained37", + "c_compare_chained37_false", + "compare_chained37", + "compare_chained37_false", + ): self.default(node[0]) else: self.default(node) - self.n_compare_chained = n_compare_chained + self.n_compare_chained = self.n_c_compare_chained = n_compare_chained def n_importlist37(node): if len(node) == 1: @@ -439,3 +443,26 @@ def customize_for_version37(self, version): self.prune() self.n_list_comp_async = n_list_comp_async + + # FIXME: The following adjusts I guess a bug in the parser. + # It might be as simple as renaming grammar symbol "testtrue" to "testtrue_or_false" + # and then keeping this as is with the name change. + # Fixing in the parsing by inspection is harder than doing it here. + def n_testtrue(node): + compare_chained37 = node[0] + if ( + compare_chained37 == "compare_chained37" + and compare_chained37[1] == "compare_chained1b_37" + ): + compare_chained1b_37 = compare_chained37[1] + if ( + len(compare_chained1b_37) > 2 + and compare_chained1b_37[-2] == "JUMP_FORWARD" + ): + node.kind = "testfalse" + pass + pass + self.default(node) + return + + self.n_testtrue = n_testtrue