You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 08:49:51 +08:00
Fix a 2.6 bug found in pyenvlib testing
This commit is contained in:
@@ -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.5.9 3.6.9 2.6.9 3.3.7 2.7.17 3.2.6 3.1.5 3.4.10 3.7.6 3.8.1'
|
||||
export PYVERSIONS='3.5.9 3.6.10 2.6.9 3.3.7 2.7.17 3.2.6 3.1.5 3.4.10 3.7.6 3.8.1'
|
||||
|
Binary file not shown.
BIN
test/bytecode_2.6_run/04_if_and_bug.pyc
Normal file
BIN
test/bytecode_2.6_run/04_if_and_bug.pyc
Normal file
Binary file not shown.
34
test/simple_source/bug26/04_if_and_bug.py
Normal file
34
test/simple_source/bug26/04_if_and_bug.py
Normal file
@@ -0,0 +1,34 @@
|
||||
def foo():
|
||||
if julian == -1 and week_of_year != -1 and weekday != -1:
|
||||
first_weekday = datetime_date(year, 1, 1).weekday()
|
||||
preceeding_days = 7 - first_weekday
|
||||
if preceeding_days == 7:
|
||||
preceeding_days = 0
|
||||
if weekday == 6 and week_of_year_start == 6:
|
||||
week_of_year -= 1
|
||||
if weekday == 0 and first_weekday == 0 and week_of_year_start == 6:
|
||||
week_of_year += 1
|
||||
if week_of_year == 0:
|
||||
julian = 1 + weekday - first_weekday
|
||||
else:
|
||||
days_to_week = preceeding_days + 7 * (week_of_year - 1)
|
||||
julian = 1 + days_to_week + weekday
|
||||
|
||||
|
||||
# 2.6 pstats.py
|
||||
# Bug is handling "for" with "elif" and "and"s.
|
||||
def eval_print_amount(a, b, c, d, list, msg=0):
|
||||
if a:
|
||||
for i in list:
|
||||
msg = 1
|
||||
elif b and c:
|
||||
msg = 2
|
||||
elif c and d:
|
||||
msg = 3
|
||||
return msg
|
||||
|
||||
assert eval_print_amount(True, False, False, False, [1]) == 1
|
||||
assert eval_print_amount(True, False, False, False, []) == 0
|
||||
assert eval_print_amount(False, True, True, False, []) == 2
|
||||
assert eval_print_amount(False, False, True, True, []) == 3
|
||||
assert eval_print_amount(False, False, False, True, []) == 0
|
@@ -169,6 +169,7 @@ class Python26Parser(Python2Parser):
|
||||
# Semantic actions want the else to be at position 3
|
||||
ifelsestmt ::= testexpr_then c_stmts_opt jf_cf_pop else_suite come_froms
|
||||
ifelsestmt ::= testexpr_then c_stmts_opt filler else_suitel come_froms POP_TOP
|
||||
ifelsestmt ::= testexpr c_stmts_opt jf_cf_pop else_suite
|
||||
|
||||
# We have no jumps to jumps, so no "come_froms" but a single "COME_FROM"
|
||||
ifelsestmt ::= testexpr c_stmts_opt jf_cf_pop else_suite COME_FROM
|
||||
|
Reference in New Issue
Block a user