diff --git a/decompyle3/parsers/p38/full_custom.py b/decompyle3/parsers/p38/full_custom.py index 5b3db33f..b92cf826 100644 --- a/decompyle3/parsers/p38/full_custom.py +++ b/decompyle3/parsers/p38/full_custom.py @@ -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, @@ -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" @@ -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 diff --git a/decompyle3/parsers/reduce_check/forelse38_check.py b/decompyle3/parsers/reduce_check/forelse38_check.py index ff4658e2..91432f2a 100644 --- a/decompyle3/parsers/reduce_check/forelse38_check.py +++ b/decompyle3/parsers/reduce_check/forelse38_check.py @@ -22,8 +22,6 @@ 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() @@ -31,7 +29,11 @@ def forelse38_invalid( # 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] diff --git a/test/stdlib/3.8-exclude.sh b/test/stdlib/3.8-exclude.sh index 8b956700..c9661964 100644 --- a/test/stdlib/3.8-exclude.sh +++ b/test/stdlib/3.8-exclude.sh @@ -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',