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
1bd03078
Commit
1bd03078
authored
Mar 02, 2016
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asyncio: Prevent StopIteration from being thrown into a Future
Patch by Chris Angelico (issue #26221)
parent
dce63234
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
+7
-0
Lib/asyncio/futures.py
Lib/asyncio/futures.py
+3
-0
Lib/test/test_asyncio/test_futures.py
Lib/test/test_asyncio/test_futures.py
+4
-0
No files found.
Lib/asyncio/futures.py
View file @
1bd03078
...
...
@@ -341,6 +341,9 @@ class Future:
raise
InvalidStateError
(
'{}: {!r}'
.
format
(
self
.
_state
,
self
))
if
isinstance
(
exception
,
type
):
exception
=
exception
()
if
type
(
exception
)
is
StopIteration
:
raise
TypeError
(
"StopIteration interacts badly with generators "
"and cannot be raised into a Future"
)
self
.
_exception
=
exception
self
.
_state
=
_FINISHED
self
.
_schedule_callbacks
()
...
...
Lib/test/test_asyncio/test_futures.py
View file @
1bd03078
...
...
@@ -76,6 +76,10 @@ class FutureTests(test_utils.TestCase):
f
=
asyncio
.
Future
(
loop
=
self
.
loop
)
self
.
assertRaises
(
asyncio
.
InvalidStateError
,
f
.
exception
)
# StopIteration cannot be raised into a Future - CPython issue26221
self
.
assertRaisesRegex
(
TypeError
,
"StopIteration .* cannot be raised"
,
f
.
set_exception
,
StopIteration
)
f
.
set_exception
(
exc
)
self
.
assertFalse
(
f
.
cancelled
())
self
.
assertTrue
(
f
.
done
())
...
...
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