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
d967fc9d
Kaydet (Commit)
d967fc9d
authored
Haz 05, 2014
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #21515: tempfile.TemporaryFile now uses os.O_TMPFILE flag is available
üst
7088b99e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
tempfile.rst
Doc/library/tempfile.rst
+7
-0
tempfile.py
Lib/tempfile.py
+26
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/tempfile.rst
Dosyayı görüntüle @
d967fc9d
...
@@ -54,6 +54,13 @@ The module defines the following user-callable items:
...
@@ -54,6 +54,13 @@ The module defines the following user-callable items:
underlying true file object. This file-like object can be used in a
underlying true file object. This file-like object can be used in a
:keyword:`with` statement, just like a normal file.
:keyword:`with` statement, just like a normal file.
The :py:data:`os.O_TMPFILE` flag is used if it is available and works
(Linux-specific, require Linux kernel 3.11 or later).
.. versionchanged:: 3.5
The :py:data:`os.O_TMPFILE` flag is now used if available.
.. function:: NamedTemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix='', prefix='tmp', dir=None, delete=True)
.. function:: NamedTemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix='', prefix='tmp', dir=None, delete=True)
...
...
Lib/tempfile.py
Dosyayı görüntüle @
d967fc9d
...
@@ -473,6 +473,11 @@ if _os.name != 'posix' or _os.sys.platform == 'cygwin':
...
@@ -473,6 +473,11 @@ if _os.name != 'posix' or _os.sys.platform == 'cygwin':
TemporaryFile
=
NamedTemporaryFile
TemporaryFile
=
NamedTemporaryFile
else
:
else
:
# Is the O_TMPFILE flag available and does it work?
# The flag is set to False if os.open(dir, os.O_TMPFILE) raises an
# IsADirectoryError exception
_O_TMPFILE_WORKS
=
hasattr
(
_os
,
'O_TMPFILE'
)
def
TemporaryFile
(
mode
=
'w+b'
,
buffering
=-
1
,
encoding
=
None
,
def
TemporaryFile
(
mode
=
'w+b'
,
buffering
=-
1
,
encoding
=
None
,
newline
=
None
,
suffix
=
""
,
prefix
=
template
,
newline
=
None
,
suffix
=
""
,
prefix
=
template
,
dir
=
None
):
dir
=
None
):
...
@@ -488,11 +493,32 @@ else:
...
@@ -488,11 +493,32 @@ else:
Returns an object with a file-like interface. The file has no
Returns an object with a file-like interface. The file has no
name, and will cease to exist when it is closed.
name, and will cease to exist when it is closed.
"""
"""
global
_O_TMPFILE_WORKS
if
dir
is
None
:
if
dir
is
None
:
dir
=
gettempdir
()
dir
=
gettempdir
()
flags
=
_bin_openflags
flags
=
_bin_openflags
if
_O_TMPFILE_WORKS
:
try
:
flags2
=
(
flags
|
_os
.
O_TMPFILE
)
&
~
_os
.
O_CREAT
fd
=
_os
.
open
(
dir
,
flags2
,
0
o600
)
except
IsADirectoryError
:
# Linux kernel older than 3.11 ignores O_TMPFILE flag.
# Set flag to None to not try again.
_O_TMPFILE_WORKS
=
False
except
OSError
:
# The filesystem of the directory does not support O_TMPFILE.
# For example, OSError(95, 'Operation not supported').
pass
else
:
try
:
return
_io
.
open
(
fd
,
mode
,
buffering
=
buffering
,
newline
=
newline
,
encoding
=
encoding
)
except
:
_os
.
close
(
fd
)
raise
# Fallback to _mkstemp_inner().
(
fd
,
name
)
=
_mkstemp_inner
(
dir
,
prefix
,
suffix
,
flags
)
(
fd
,
name
)
=
_mkstemp_inner
(
dir
,
prefix
,
suffix
,
flags
)
try
:
try
:
...
...
Misc/NEWS
Dosyayı görüntüle @
d967fc9d
...
@@ -88,6 +88,8 @@ Core and Builtins
...
@@ -88,6 +88,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #21515: tempfile.TemporaryFile now uses os.O_TMPFILE flag is available.
- Issue #21618: The subprocess module could fail to close open fds that were
- Issue #21618: The subprocess module could fail to close open fds that were
inherited by the calling process and already higher than POSIX resource
inherited by the calling process and already higher than POSIX resource
limits would otherwise allow. On systems with a functioning /proc/self/fd
limits would otherwise allow. On systems with a functioning /proc/self/fd
...
...
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