Merge pull request #352 from rocky/lambda-bug

Fixes #360
This commit is contained in:
R. Bernstein 2021-06-15 22:46:46 -04:00 committed by GitHub
commit dd8f22e698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,4 @@
# From https://github.com/rocky/python-uncompyle6/issues/350
# This is RUNNABLE!
a = (lambda x: x)(abs)
assert a(-3) == 3

View File

@ -1,4 +1,4 @@
# Copyright (c) 2019-2020 by Rocky Bernstein # Copyright (c) 2019-2021 by Rocky Bernstein
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -275,11 +275,16 @@ def customize_for_version37(self, version):
and opname == "CALL_FUNCTION_1" and opname == "CALL_FUNCTION_1"
or not re.match(r"\d", opname[-1]) or not re.match(r"\d", opname[-1])
): ):
if node[0][0] == "_mklambda":
template = "(%c)(%p)"
else:
template = "%c(%p)"
self.template_engine( self.template_engine(
("%c(%p)", (template,
(0, "expr"), (0, "expr"),
(1, PRECEDENCE["yield"]-1)), (1, PRECEDENCE["yield"]-1)),
node) node
)
self.prec = p self.prec = p
self.prune() self.prune()
else: else: