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
52a05ab5
Kaydet (Commit)
52a05ab5
authored
Mar 18, 2015
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #23353: improve exceptions tests for generators
üst
009b811d
c4c19b39
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
test_exceptions.py
Lib/test/test_exceptions.py
+46
-0
No files found.
Lib/test/test_exceptions.py
Dosyayı görüntüle @
52a05ab5
...
...
@@ -661,6 +661,52 @@ class ExceptionTests(unittest.TestCase):
pass
self
.
assertEqual
(
sys
.
exc_info
(),
(
None
,
None
,
None
))
def
test_generator_leaking3
(
self
):
# See issue #23353. When gen.throw() is called, the caller's
# exception state should be save and restored.
def
g
():
try
:
yield
except
ZeroDivisionError
:
yield
sys
.
exc_info
()[
1
]
it
=
g
()
next
(
it
)
try
:
1
/
0
except
ZeroDivisionError
as
e
:
self
.
assertIs
(
sys
.
exc_info
()[
1
],
e
)
gen_exc
=
it
.
throw
(
e
)
self
.
assertIs
(
sys
.
exc_info
()[
1
],
e
)
self
.
assertIs
(
gen_exc
,
e
)
self
.
assertEqual
(
sys
.
exc_info
(),
(
None
,
None
,
None
))
def
test_generator_leaking4
(
self
):
# See issue #23353. When an exception is raised by a generator,
# the caller's exception state should still be restored.
def
g
():
try
:
1
/
0
except
ZeroDivisionError
:
yield
sys
.
exc_info
()[
0
]
raise
it
=
g
()
try
:
raise
TypeError
except
TypeError
:
# The caller's exception state (TypeError) is temporarily
# saved in the generator.
tp
=
next
(
it
)
self
.
assertIs
(
tp
,
ZeroDivisionError
)
try
:
next
(
it
)
# We can't check it immediately, but while next() returns
# with an exception, it shouldn't have restored the old
# exception state (TypeError).
except
ZeroDivisionError
as
e
:
self
.
assertIs
(
sys
.
exc_info
()[
1
],
e
)
# We used to find TypeError here.
self
.
assertEqual
(
sys
.
exc_info
(),
(
None
,
None
,
None
))
def
test_generator_doesnt_retain_old_exc
(
self
):
def
g
():
self
.
assertIsInstance
(
sys
.
exc_info
()[
1
],
RuntimeError
)
...
...
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