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
e53fcfd7
Commit
e53fcfd7
authored
Nov 07, 2007
by
Nick Coghlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue #1705170 (backport from trunk)
parent
2e49f781
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
Lib/contextlib.py
Lib/contextlib.py
+4
-0
Lib/test/test_with.py
Lib/test/test_with.py
+17
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/contextlib.py
View file @
e53fcfd7
...
...
@@ -25,6 +25,10 @@ class GeneratorContextManager(object):
else
:
raise
RuntimeError
(
"generator didn't stop"
)
else
:
if
value
is
None
:
# Need to force instantiation so we can reliably
# tell if we get the same exception back
value
=
type
()
try
:
self
.
gen
.
throw
(
type
,
value
,
traceback
)
raise
RuntimeError
(
"generator didn't stop after throw()"
)
...
...
Lib/test/test_with.py
View file @
e53fcfd7
...
...
@@ -440,6 +440,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
self
.
assertAfterWithGeneratorInvariantsNoError
(
self
.
bar
)
def
testRaisedStopIteration1
(
self
):
# From bug 1462485
@
contextmanager
def
cm
():
yield
...
...
@@ -451,6 +452,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
self
.
assertRaises
(
StopIteration
,
shouldThrow
)
def
testRaisedStopIteration2
(
self
):
# From bug 1462485
class
cm
(
object
):
def
__enter__
(
self
):
pass
...
...
@@ -463,7 +465,21 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
self
.
assertRaises
(
StopIteration
,
shouldThrow
)
def
testRaisedStopIteration3
(
self
):
# Another variant where the exception hasn't been instantiated
# From bug 1705170
@
contextmanager
def
cm
():
yield
def
shouldThrow
():
with
cm
():
raise
iter
([]).
next
()
self
.
assertRaises
(
StopIteration
,
shouldThrow
)
def
testRaisedGeneratorExit1
(
self
):
# From bug 1462485
@
contextmanager
def
cm
():
yield
...
...
@@ -475,6 +491,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
self
.
assertRaises
(
GeneratorExit
,
shouldThrow
)
def
testRaisedGeneratorExit2
(
self
):
# From bug 1462485
class
cm
(
object
):
def
__enter__
(
self
):
pass
...
...
Misc/NEWS
View file @
e53fcfd7
...
...
@@ -32,6 +32,9 @@ Core and builtins
Library
-------
- Issue #1705170: contextlib.contextmanager was still swallowing
StopIteration in some cases. This should no longer happen.
- Bug #1307: Fix smtpd so it doesn'
t
raise
an
exception
when
there
is
no
arg
.
-
ctypes
will
now
work
correctly
on
32
-
bit
systems
when
Python
is
...
...
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