Another kind of yield_from on 3.5

This commit is contained in:
rocky 2016-06-22 16:48:03 -04:00
parent 126af429fb
commit f999e6a33a
7 changed files with 31 additions and 11 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,11 +0,0 @@
# Python 3.3 and above only
# Tests
# 3.3, 3.4
# yield_from ::= expr expr YIELD_FROM
# expr ::= yield_from
# 3.5:
def _walk_dir(dir, ddir=None):
yield from _walk_dir(dir, ddir=dfile)

View File

@ -0,0 +1,27 @@
# Python 3.3 and above only
# Tests
# 3.3, 3.4
# yield_from ::= expr expr YIELD_FROM
# expr ::= yield_from
# 3.5:
# yield_from ::= expr GET_YIELD_FROM_ITER LOAD_CONST YIELD_FROM
def _walk_dir(dir, dfile, ddir=None):
yield from _walk_dir(dir, ddir=dfile)
# From 3.5.1 _wakrefset.py
#
# 3.5:
# withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
# POP_BLOCK LOAD_CONST COME_FROM
# WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
def __iter__(self, IterationGuard):
with IterationGuard(self):
for itemref in self.data:
item = itemref()
if item is not None:
yield item

View File

@ -582,6 +582,10 @@ class Python35onParser(Python3Parser):
# Python 3.5+ has WITH_CLEANUP_START/FINISH
withstmt ::= expr SETUP_WITH exprlist suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY