2.6. with fn()

This commit is contained in:
rocky 2016-06-28 10:53:03 -04:00
parent ae980e4f64
commit 74c6b38fd8
3 changed files with 20 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,11 @@
# Python 2.6 has a truly weird way of handling with here.
# added rule for 2.6
# setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP
import sys
from warnings import catch_warnings
with catch_warnings():
if sys.py3kwarning:
sys.filterwarnings("ignore", ".*mimetools has been removed",
DeprecationWarning)
import mimetools

View File

@ -85,6 +85,15 @@ class Python26Parser(Python2Parser):
"""
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 come_from_pop
ifelsestmt ::= testexpr c_stmts_opt jf_pop else_suite COME_FROM
# This rule is contorted a little to make sutie_stmts_opt be the
# forth argument for the semantic routines.
withstmt ::= expr setupwith SETUP_FINALLY suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
# This is truly weird. 2.7 does this (not including POP_TOP) with
# opcode SETUP_WITH
setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP
"""
def p_comp26(self, args):