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
56cefa69
Kaydet (Commit)
56cefa69
authored
Mar 19, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23700: Iterator of NamedTemporaryFile now keeps a reference to
NamedTemporaryFile instance. Patch by Bohuslav Kabrda.
üst
86fdbf31
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
tempfile.py
Lib/tempfile.py
+3
-1
test_tempfile.py
Lib/test/test_tempfile.py
+13
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/tempfile.py
Dosyayı görüntüle @
56cefa69
...
...
@@ -426,7 +426,9 @@ class _TemporaryFileWrapper:
# iter() doesn't use __getattr__ to find the __iter__ method
def
__iter__
(
self
):
return
iter
(
self
.
file
)
# don't return iter(self.file), but yield from it to avoid closing
# file as long as it's being used as iterator, see issue #23000
yield
from
iter
(
self
.
file
)
def
NamedTemporaryFile
(
mode
=
'w+b'
,
buffering
=-
1
,
encoding
=
None
,
...
...
Lib/test/test_tempfile.py
Dosyayı görüntüle @
56cefa69
...
...
@@ -707,6 +707,19 @@ class TestNamedTemporaryFile(BaseTestCase):
# No reference cycle was created.
self
.
assertIsNone
(
wr
())
def
test_iter
(
self
):
# Issue #23700: getting iterator from a temporary file should keep
# it alive as long as it's being iterated over
lines
=
[
b
'spam
\n
'
,
b
'eggs
\n
'
,
b
'beans
\n
'
]
def
make_file
():
f
=
tempfile
.
NamedTemporaryFile
(
mode
=
'w+b'
)
f
.
write
(
b
''
.
join
(
lines
))
f
.
seek
(
0
)
return
f
for
i
,
l
in
enumerate
(
make_file
()):
self
.
assertEqual
(
l
,
lines
[
i
])
self
.
assertEqual
(
i
,
len
(
lines
)
-
1
)
def
test_creates_named
(
self
):
# NamedTemporaryFile creates files with names
f
=
tempfile
.
NamedTemporaryFile
()
...
...
Misc/NEWS
Dosyayı görüntüle @
56cefa69
...
...
@@ -18,6 +18,9 @@ Core and Builtins
Library
-------
- Issue #23700: Iterator of NamedTemporaryFile now keeps a reference to
NamedTemporaryFile instance. Patch by Bohuslav Kabrda.
- Issue #22903: The fake test case created by unittest.loader when it fails
importing a test module is now picklable.
...
...
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