From bffbd0b3526bb865e90f1ba4602bf2c85cdec9c4 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 23 Dec 2019 07:19:40 -0500 Subject: [PATCH] 3.6+ lambda params; add semantic rule customizing for lambdas --- test/bytecode_3.6_run/04_lambda_star_default.pyc | Bin 0 -> 668 bytes test/bytecode_3.7_run/04_lambda_star_default.pyc | Bin 0 -> 657 bytes uncompyle6/parser.py | 1 - uncompyle6/semantics/make_function.py | 2 +- uncompyle6/semantics/pysource.py | 3 ++- 5 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 test/bytecode_3.6_run/04_lambda_star_default.pyc create mode 100644 test/bytecode_3.7_run/04_lambda_star_default.pyc diff --git a/test/bytecode_3.6_run/04_lambda_star_default.pyc b/test/bytecode_3.6_run/04_lambda_star_default.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8ac86b76907393eb03a46d89bf28ba292ece0e96 GIT binary patch literal 668 zcmZ9J%}T>S5XWaWsn*ukuU-USAc9q>$5Isa>On!FP)eFfHQ1WEn<7fR*!l!s#k;SR ztEb*QdC{3oMR8$fC%??h{%5yVDixkyzgiy%@D6{L%kdtYIb%maIDsaRB4+|rJcKbe zF+_6Lf#%0Zr7LAN6ZI%8$1KlmiCJUD=9n!oTVZx0j0&gVtp3)5AYvJ<$^(v&-~|auP1FdV)s4%-91pcr z1Z*HJPN6eL01A2g~z ze{C6GiK_0Tc>Ax(XW_TPwh>ixpci>W`Z2OuD;ZkKkksf^i5)v-Gba~q((=ABp-!Us`bg_o|Iuona5i;6reQB^*mse) L&pTyR!3ur@Ed_nb literal 0 HcmV?d00001 diff --git a/test/bytecode_3.7_run/04_lambda_star_default.pyc b/test/bytecode_3.7_run/04_lambda_star_default.pyc new file mode 100644 index 0000000000000000000000000000000000000000..14f22521fe50ad8e2bb07aede1f2d0e3513168dc GIT binary patch literal 657 zcmZ9J!Ac`R5QeLICT@%-3g)t~FED~p(4z!h*Q*DG6#^0_Q=>bW?8NQ~;*z~=vQMyA z@$M_l)l<%T^5Xv0DvAZwQ~ga<^-8GJ{@y&DJTTFnZeGnG*nzw6ScHV9)FCkv zOi99TG~o`XES1kBa}$Z+CBHnbxoj}(r(KtiY?7|`MrWIw>l<6$emv+& z+;vFqN_rZP`bBGaRffYjIbYB-{K0H1h!bt6rc8ks@dZH!87Ix(JZ7P578Wx#WBz9@ zLI?{Ywpx+ENn7Y9fFHx1UToo~m^@E`Z0#KxUt~4$Z4Mh^TUNK9Ww#sH-NWhE%C=-l zk>rD6yY>3lm*GlGYop}L4^19xZx!0c4?0Iy^+dr;b16X)OTWz0b?qkh`<5224; K4H~A&P5uw;mwQhD literal 0 HcmV?d00001 diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 9185a8c3..f30d6cf4 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -101,7 +101,6 @@ class PythonParser(GenericASTBuilder): many arguments it has. Often it is not used. """ if rule not in self.new_rules: - # print("XXX ", rule) # debug self.new_rules.add(rule) self.addRule(rule, nop_func) customize[opname] = arg_count diff --git a/uncompyle6/semantics/make_function.py b/uncompyle6/semantics/make_function.py index 62d7c30e..7a9a75bf 100644 --- a/uncompyle6/semantics/make_function.py +++ b/uncompyle6/semantics/make_function.py @@ -798,7 +798,7 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None): params.reverse() else: params.append("*%s" % code.co_varnames[argc]) - if not is_lambda: + if not is_lambda or self.version >= 3.6: argc += 1 # dump parameter list (with default values) diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 6b146a91..e7307597 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -484,7 +484,7 @@ class SourceWalker(GenericASTTraversal, object): else: # We can't comment out like above because there may be a trailing ')' # that needs to be written - assert len(node) == 3 and node[2] == "LAMBDA_MARKER" + assert len(node) == 3 and node[2] in ("RETURN_VALUE_LAMBDA", "LAMBDA_MARKER") self.preorder(node[0]) self.prune() @@ -2366,6 +2366,7 @@ class SourceWalker(GenericASTTraversal, object): p_insts = self.p.insts self.p.insts = self.scanner.insts ast = python_parser.parse(self.p, tokens, customize) + self.customize(customize) self.p.insts = p_insts except (python_parser.ParserError, AssertionError) as e: raise ParserError(e, tokens)