Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b37df519
Commit
b37df519
authored
Aug 06, 2012
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix yield from return value on custom iterators (closes #15568)
parent
a0abb440
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
Lib/test/test_pep380.py
Lib/test/test_pep380.py
+14
-0
Misc/NEWS
Misc/NEWS
+3
-0
Python/ceval.c
Python/ceval.c
+1
-1
No files found.
Lib/test/test_pep380.py
View file @
b37df519
...
...
@@ -940,6 +940,20 @@ class TestPEP380Operation(unittest.TestCase):
for
stack
in
spam
(
eggs
(
gen
())):
self
.
assertTrue
(
'spam'
in
stack
and
'eggs'
in
stack
)
def
test_custom_iterator_return
(
self
):
# See issue #15568
class
MyIter
:
def
__iter__
(
self
):
return
self
def
__next__
(
self
):
raise
StopIteration
(
42
)
def
gen
():
nonlocal
ret
ret
=
yield
from
MyIter
()
ret
=
None
list
(
gen
())
self
.
assertEqual
(
ret
,
42
)
def
test_main
():
from
test
import
support
...
...
Misc/NEWS
View file @
b37df519
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Beta 2?
Core and Builtins
-----------------
- Issue #15568: Fix the return value of "yield from" when StopIteration is
raised by a custom iterator.
- Issue #13119: sys.stdout and sys.stderr are now using "\r\n" newline on
Windows, as Python 2.
...
...
Python/ceval.c
View file @
b37df519
...
...
@@ -1843,7 +1843,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
}
else
{
_Py_IDENTIFIER
(
send
);
if
(
u
==
Py_None
)
retval
=
Py
Iter_N
ext
(
x
);
retval
=
Py
_TYPE
(
x
)
->
tp_itern
ext
(
x
);
else
retval
=
_PyObject_CallMethodId
(
x
,
&
PyId_send
,
"O"
,
u
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment