You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Address dead code in lambda ifelse
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -3,3 +3,14 @@
|
||||
|
||||
f = lambda x: 1 if x<2 else 3
|
||||
f(5)
|
||||
|
||||
# If that wasn't enough ...
|
||||
# Python will create dead code
|
||||
# in the below. So we must make sure
|
||||
# not to include the else expression
|
||||
|
||||
g = lambda: 1 if True else 3
|
||||
g()
|
||||
|
||||
h = lambda: 1 if False else 3
|
||||
h()
|
||||
|
@@ -175,9 +175,9 @@ TABLE_DIRECT = {
|
||||
'ret_cond_not': ( '%p if not %p else %p', (2, 27), (0, 22), (-1, 27) ),
|
||||
'conditional_lambda': ( '%c if %c else %c', 2, 0, 4),
|
||||
|
||||
# Sometiems a semicolon is neede because Python 3.x can have be
|
||||
# dead code as a result of its optimization?
|
||||
'return_lambda': ('%c', 0),
|
||||
# Python 3.x can have be dead code as a result of its optimization?
|
||||
# So we'll add a # at the end of the return lambda so the rest is ignored
|
||||
'return_lambda': ('%c # Avoid dead code: ', 0),
|
||||
|
||||
'compare': ( '%p %[-1]{pattr.replace("-", " ")} %p', (0, 19), (1, 19) ),
|
||||
'cmp_list': ( '%p %p', (0, 29), (1, 30)),
|
||||
|
Reference in New Issue
Block a user