Skip to content

Commit

Permalink
add 3.8 forelese reduction check
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Aug 18, 2023
1 parent 4c901de commit 274463c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions decompyle3/parsers/p38/full_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from decompyle3.parsers.reduce_check import ( # joined_str_check,
break_invalid,
for38_invalid,
forelse38_invalid,
if_not_stmtc_invalid,
pop_return_check,
whilestmt38_check,
Expand Down Expand Up @@ -787,6 +788,8 @@ def customize_reduce_checks_full38(self, tokens, customize):
self.check_reduce["testfalsec"] = "tokens"

self.check_reduce["break"] = "tokens"
self.check_reduce["forelselaststmt38"] = "AST"
self.check_reduce["forelselaststmtc38"] = "AST"
self.check_reduce["for38"] = "tokens"
self.check_reduce["ifstmt"] = "AST"
self.check_reduce["joined_str"] = "AST"
Expand All @@ -798,6 +801,8 @@ def customize_reduce_checks_full38(self, tokens, customize):
self.reduce_check_table["break"] = break_invalid
self.reduce_check_table["if_not_stmtc"] = if_not_stmtc_invalid
self.reduce_check_table["for38"] = for38_invalid
self.reduce_check_table["forelselaststmt38"] = forelse38_invalid
self.reduce_check_table["forelselaststmtc38"] = forelse38_invalid
# self.reduce_check_table["joined_str"] = joined_str_check.joined_str_invalid
self.reduce_check_table["or"] = or_cond_check_invalid
self.reduce_check_table["pop_return"] = pop_return_check
Expand Down
8 changes: 5 additions & 3 deletions decompyle3/parsers/reduce_check/forelse38_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ def forelse38_invalid(
for_iter.
"""

come_froms = tree[5]
else_start = come_froms.first_child().off2int()
saw_break = False
saw_break_to_last = False
last_offset = tokens[last].off2int()

# for i in range(first, last):
# print(tokens[i])

# print("XXX", else_start, last_offset)
else_start = None
for node in tree:
if node.kind.startswith("else"):
else_start = node.first_child().off2int()
assert else_start is not None

for i in range(first, last):
t = tokens[i]
Expand Down
4 changes: 0 additions & 4 deletions test/stdlib/3.8-exclude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,11 @@ SKIP_TESTS=(
[test_venv.py]=1 # Fails on its own
[test_zipimport.py]=1 # test failures; works on uncompyle6

[test_profile.py]=1 # FIXME: break outside of loop! works in c28a3d1c
[test_type_comments.py]=1 # test fails; works in c28a3d1c
# And others!

[test_c_locale_coercion.py]=1 # FIXME: parse error works in a810b68e

[test_nis.py]=1 # FIXME: works on ac5594b0; probably a "for38" reduction check
# SyntaxError: 'break' outside loop

[test__xxsubinterpreters.py]=1 # FIXME: works on ac5594b0; probably a "for38" reduction checks
# self.end not in ('same', 'opposite', 'send', 'recv')ValueErrorself.end elif self.action in ('close',

Expand Down

0 comments on commit 274463c

Please sign in to comment.