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
367f5d37
Kaydet (Commit)
367f5d37
authored
Mar 25, 2014
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #21058: Fix a leak of file descriptor in tempfile.NamedTemporaryFile(),
close the file descriptor if os.fdopen() fails
üst
74a4ebae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
tempfile.py
Lib/tempfile.py
+6
-2
test_tempfile.py
Lib/test/test_tempfile.py
+18
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/tempfile.py
Dosyayı görüntüle @
367f5d37
...
@@ -460,8 +460,12 @@ def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="",
...
@@ -460,8 +460,12 @@ def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="",
flags
|=
_os
.
O_TEMPORARY
flags
|=
_os
.
O_TEMPORARY
(
fd
,
name
)
=
_mkstemp_inner
(
dir
,
prefix
,
suffix
,
flags
)
(
fd
,
name
)
=
_mkstemp_inner
(
dir
,
prefix
,
suffix
,
flags
)
file
=
_os
.
fdopen
(
fd
,
mode
,
bufsize
)
try
:
return
_TemporaryFileWrapper
(
file
,
name
,
delete
)
file
=
_os
.
fdopen
(
fd
,
mode
,
bufsize
)
return
_TemporaryFileWrapper
(
file
,
name
,
delete
)
except
Exception
:
_os
.
close
(
fd
)
raise
if
_os
.
name
!=
'posix'
or
_os
.
sys
.
platform
==
'cygwin'
:
if
_os
.
name
!=
'posix'
or
_os
.
sys
.
platform
==
'cygwin'
:
# On non-POSIX and Cygwin systems, assume that we cannot unlink a file
# On non-POSIX and Cygwin systems, assume that we cannot unlink a file
...
...
Lib/test/test_tempfile.py
Dosyayı görüntüle @
367f5d37
...
@@ -771,6 +771,24 @@ class test_NamedTemporaryFile(TC):
...
@@ -771,6 +771,24 @@ class test_NamedTemporaryFile(TC):
pass
pass
self
.
assertRaises
(
ValueError
,
use_closed
)
self
.
assertRaises
(
ValueError
,
use_closed
)
def
test_no_leak_fd
(
self
):
# Issue #21058: don't leak file descriptor when fdopen() fails
old_close
=
os
.
close
old_fdopen
=
os
.
fdopen
closed
=
[]
def
close
(
fd
):
closed
.
append
(
fd
)
def
fdopen
(
*
args
):
raise
ValueError
()
os
.
close
=
close
os
.
fdopen
=
fdopen
try
:
self
.
assertRaises
(
ValueError
,
tempfile
.
NamedTemporaryFile
)
self
.
assertEqual
(
len
(
closed
),
1
)
finally
:
os
.
close
=
old_close
os
.
fdopen
=
old_fdopen
# How to test the mode and bufsize parameters?
# How to test the mode and bufsize parameters?
test_classes
.
append
(
test_NamedTemporaryFile
)
test_classes
.
append
(
test_NamedTemporaryFile
)
...
...
Misc/NEWS
Dosyayı görüntüle @
367f5d37
...
@@ -40,6 +40,9 @@ Core and Builtins
...
@@ -40,6 +40,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #21058: Fix a leak of file descriptor in tempfile.NamedTemporaryFile(),
close the file descriptor if os.fdopen() fails
- Issue #20283: RE pattern methods now accept the string keyword parameters
- Issue #20283: RE pattern methods now accept the string keyword parameters
as documented. The pattern and source keyword parameters are left as
as documented. The pattern and source keyword parameters are left as
deprecated aliases.
deprecated aliases.
...
...
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