Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
3814a911
Kaydet (Commit)
3814a911
authored
Kas 02, 2007
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix for bug 1705170 - contextmanager swallowing StopIteration (2.5 backport candidate)
üst
ac3d429e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
contextlib.py
Lib/contextlib.py
+4
-0
test_with.py
Lib/test/test_with.py
+17
-0
No files found.
Lib/contextlib.py
Dosyayı görüntüle @
3814a911
...
...
@@ -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
Dosyayı görüntüle @
3814a911
...
...
@@ -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
...
...
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