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
d979c721
Kaydet (Commit)
d979c721
authored
Tem 27, 2013
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add a test for issue #17669 (closes #18565)
Patch from Phil Connell.
üst
9eda66da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
1 deletion
+40
-1
test_pep380.py
Lib/test/test_pep380.py
+40
-1
No files found.
Lib/test/test_pep380.py
Dosyayı görüntüle @
d979c721
...
...
@@ -13,7 +13,7 @@ import sys
import
inspect
import
parser
from
test.support
import
captured_stderr
from
test.support
import
captured_stderr
,
disable_gc
,
gc_collect
class
TestPEP380Operation
(
unittest
.
TestCase
):
"""
...
...
@@ -954,6 +954,45 @@ class TestPEP380Operation(unittest.TestCase):
list
(
gen
())
self
.
assertEqual
(
ret
,
42
)
def
test_close_with_cleared_frame
(
self
):
# See issue #17669.
#
# Create a stack of generators: outer() delegating to inner()
# delegating to innermost(). The key point is that the instance of
# inner is created first: this ensures that its frame appears before
# the instance of outer in the GC linked list.
#
# At the gc.collect call:
# - frame_clear is called on the inner_gen frame.
# - gen_dealloc is called on the outer_gen generator (the only
# reference is in the frame's locals).
# - gen_close is called on the outer_gen generator.
# - gen_close_iter is called to close the inner_gen generator, which
# in turn calls gen_close, and gen_yf.
#
# Previously, gen_yf would crash since inner_gen's frame had been
# cleared (and in particular f_stacktop was NULL).
def
innermost
():
yield
def
inner
():
outer_gen
=
yield
yield
from
innermost
()
def
outer
():
inner_gen
=
yield
yield
from
inner_gen
with
disable_gc
():
inner_gen
=
inner
()
outer_gen
=
outer
()
outer_gen
.
send
(
None
)
outer_gen
.
send
(
inner_gen
)
outer_gen
.
send
(
outer_gen
)
del
outer_gen
del
inner_gen
gc_collect
()
def
test_main
():
from
test
import
support
...
...
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