You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +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
|
||||
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
||||
|
||||
|
||||
# Python 3.5+ async additions
|
||||
|
||||
stmt ::= async_for_stmt
|
||||
async_for_stmt ::= SETUP_LOOP expr
|
||||
GET_AITER
|
||||
@@ -142,6 +140,7 @@ class Python35Parser(Python34Parser):
|
||||
rule = 'call ::= expr unmapexpr ' + call_token.kind
|
||||
self.addRule(rule, nop_func)
|
||||
elif opname == 'BEFORE_ASYNC_WITH':
|
||||
# Some Python 3.5+ async additions
|
||||
rules_str = """
|
||||
async_with_stmt ::= expr
|
||||
stmt ::= async_with_stmt
|
||||
@@ -171,6 +170,20 @@ class Python35Parser(Python34Parser):
|
||||
unmap_dict ::= dict_comp BUILD_MAP_UNPACK
|
||||
""", 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
|
||||
return
|
||||
|
||||
|
Reference in New Issue
Block a user