You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
DRY 3.{5,6} SETUP_WITH a little bit
This commit is contained in:
@@ -54,9 +54,7 @@ class Python35Parser(Python34Parser):
|
|||||||
POP_BLOCK LOAD_CONST COME_FROM_WITH
|
POP_BLOCK LOAD_CONST COME_FROM_WITH
|
||||||
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
||||||
|
|
||||||
|
|
||||||
# Python 3.5+ async additions
|
# Python 3.5+ async additions
|
||||||
|
|
||||||
stmt ::= async_for_stmt
|
stmt ::= async_for_stmt
|
||||||
async_for_stmt ::= SETUP_LOOP expr
|
async_for_stmt ::= SETUP_LOOP expr
|
||||||
GET_AITER
|
GET_AITER
|
||||||
@@ -142,6 +140,7 @@ class Python35Parser(Python34Parser):
|
|||||||
rule = 'call ::= expr unmapexpr ' + call_token.kind
|
rule = 'call ::= expr unmapexpr ' + call_token.kind
|
||||||
self.addRule(rule, nop_func)
|
self.addRule(rule, nop_func)
|
||||||
elif opname == 'BEFORE_ASYNC_WITH':
|
elif opname == 'BEFORE_ASYNC_WITH':
|
||||||
|
# Some Python 3.5+ async additions
|
||||||
rules_str = """
|
rules_str = """
|
||||||
async_with_stmt ::= expr
|
async_with_stmt ::= expr
|
||||||
stmt ::= async_with_stmt
|
stmt ::= async_with_stmt
|
||||||
@@ -171,6 +170,20 @@ class Python35Parser(Python34Parser):
|
|||||||
unmap_dict ::= dict_comp BUILD_MAP_UNPACK
|
unmap_dict ::= dict_comp BUILD_MAP_UNPACK
|
||||||
""", nop_func)
|
""", nop_func)
|
||||||
|
|
||||||
|
elif opname == 'SETUP_WITH':
|
||||||
|
# Python 3.5+ has WITH_CLEANUP_START/FINISH
|
||||||
|
rules_str = """
|
||||||
|
withstmt ::= expr
|
||||||
|
SETUP_WITH POP_TOP suite_stmts_opt
|
||||||
|
POP_BLOCK LOAD_CONST COME_FROM_WITH
|
||||||
|
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
||||||
|
|
||||||
|
withasstmt ::= expr
|
||||||
|
SETUP_WITH store suite_stmts_opt
|
||||||
|
POP_BLOCK LOAD_CONST COME_FROM_WITH
|
||||||
|
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
||||||
|
"""
|
||||||
|
self.addRule(rules_str, nop_func)
|
||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@@ -27,9 +27,6 @@ class Python36Parser(Python35Parser):
|
|||||||
return_if_lambda ::= RETURN_END_IF_LAMBDA
|
return_if_lambda ::= RETURN_END_IF_LAMBDA
|
||||||
|
|
||||||
|
|
||||||
withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt POP_BLOCK LOAD_CONST
|
|
||||||
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
|
||||||
|
|
||||||
for_block ::= l_stmts_opt come_from_loops JUMP_BACK
|
for_block ::= l_stmts_opt come_from_loops JUMP_BACK
|
||||||
come_from_loops ::= COME_FROM_LOOP*
|
come_from_loops ::= COME_FROM_LOOP*
|
||||||
|
|
||||||
@@ -107,6 +104,12 @@ class Python36Parser(Python35Parser):
|
|||||||
%s ::= %sBUILD_STRING
|
%s ::= %sBUILD_STRING
|
||||||
""" % (joined_str_n, joined_str_n, "formatted_value " * v)
|
""" % (joined_str_n, joined_str_n, "formatted_value " * v)
|
||||||
self.add_unique_doc_rules(rules_str, customize)
|
self.add_unique_doc_rules(rules_str, customize)
|
||||||
|
elif opname == 'SETUP_WITH':
|
||||||
|
rules_str = """
|
||||||
|
withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt POP_BLOCK LOAD_CONST
|
||||||
|
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
||||||
|
"""
|
||||||
|
self.addRule(rules_str, nop_func)
|
||||||
|
|
||||||
def custom_classfunc_rule(self, opname, token, customize,
|
def custom_classfunc_rule(self, opname, token, customize,
|
||||||
possible_class_decorator,
|
possible_class_decorator,
|
||||||
|
Reference in New Issue
Block a user