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
e557da80
Commit
e557da80
authored
Jan 13, 2012
by
Amaury Forgeot d'Arc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a crash when the return value of a subgenerator is a temporary
object (with a refcount of 1)
parent
7e447c82
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
Lib/test/test_pep380.py
Lib/test/test_pep380.py
+11
-0
Objects/genobject.c
Objects/genobject.c
+2
-1
No files found.
Lib/test/test_pep380.py
View file @
e557da80
...
...
@@ -364,6 +364,17 @@ class TestPEP380Operation(unittest.TestCase):
])
def
test_exception_value_crash
(
self
):
# There used to be a refcount error when the return value
# stored in the StopIteration has a refcount of 1.
def
g1
():
yield
from
g2
()
def
g2
():
yield
"g2"
return
[
42
]
self
.
assertEqual
(
list
(
g1
()),
[
"g2"
])
def
test_generator_return_value
(
self
):
"""
Test generator return value
...
...
Objects/genobject.c
View file @
e557da80
...
...
@@ -475,6 +475,7 @@ PyGen_FetchStopIterationValue(PyObject **pvalue) {
Py_XDECREF
(
tb
);
if
(
ev
)
{
value
=
((
PyStopIterationObject
*
)
ev
)
->
value
;
Py_INCREF
(
value
);
Py_DECREF
(
ev
);
}
}
else
if
(
PyErr_Occurred
())
{
...
...
@@ -482,8 +483,8 @@ PyGen_FetchStopIterationValue(PyObject **pvalue) {
}
if
(
value
==
NULL
)
{
value
=
Py_None
;
Py_INCREF
(
value
);
}
Py_INCREF
(
value
);
*
pvalue
=
value
;
return
0
;
}
...
...
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