Trystmt grammar from 3.3 needed in 3.2

Add test to cover this
This commit is contained in:
rocky
2017-11-23 14:29:31 -05:00
parent a94b844988
commit 0e54c37fab
3 changed files with 28 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,21 @@
# From 3.2 distutils/core
# Ensure we handle funky trystmt
def setup (ok, dist, **attrs):
if ok:
try:
dist.run_commands()
except KeyboardInterrupt:
raise SystemExit("interrupted")
except IOError as exc:
error = exc
if dist:
raise
else:
raise SystemExit(error)
except (RuntimeError) as msg:
if dist:
raise
else:
raise SystemExit("error: " + str(msg))
return dist

View File

@@ -21,6 +21,13 @@ class Python32Parser(Python3Parser):
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM_LOOP
whileTruestmt ::= SETUP_LOOP return_stmts COME_FROM_LOOP
# Python 3.5+ has jump optimization to remove the redundant
# jump_excepts. But in 3.3 we need them added
trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
try_middle
jump_excepts come_from_except_clauses
try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts
END_FINALLY