Fix a 2.6 bug found in pyenvlib testing

This commit is contained in:
rocky
2020-01-14 22:30:48 -05:00
parent 585dcfb8ce
commit 3c2dafe74c
5 changed files with 36 additions and 1 deletions

View File

@@ -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.

Binary file not shown.

View 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

View File

@@ -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