summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-11-30 00:16:44 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-11-30 00:16:44 (GMT)
commit36dfe784568b2d01bc03b3151ff6974b8ba42acf (patch)
treedd4f4fd5f97578d2a0e5d4b6a12c22de73757b08 /Lib/tempfile.py
parentac4a07c714fbe5560cd1204c1335e5fcea4b2ef3 (diff)
downloadcpython-36dfe784568b2d01bc03b3151ff6974b8ba42acf.zip
cpython-36dfe784568b2d01bc03b3151ff6974b8ba42acf.tar.gz
cpython-36dfe784568b2d01bc03b3151ff6974b8ba42acf.tar.bz2
Merged revisions 76593 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r76593 | amaury.forgeotdarc | 2009-11-30 01:08:56 +0100 (lun., 30 nov. 2009) | 5 lines #6077: on Windows, fix truncation of a tempfile.TemporaryFile opened in "wt+" mode: files opened with os.open() stop on the first \x1a (Ctrl-Z) unless os.O_BINARY is used. Will backport to 3.1 ........
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py13
1 files changed, 3 insertions, 10 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 93405a8..049cdaa 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -169,7 +169,6 @@ def _get_default_tempdir():
namer = _RandomNameSequence()
dirlist = _candidate_tempdir_list()
- flags = _text_openflags
for dir in dirlist:
if dir != _os.curdir:
@@ -179,7 +178,7 @@ def _get_default_tempdir():
name = next(namer)
filename = _os.path.join(dir, name)
try:
- fd = _os.open(filename, flags, 0o600)
+ fd = _os.open(filename, _bin_openflags, 0o600)
fp = _io.open(fd, 'wb')
fp.write(b'blat')
fp.close()
@@ -434,10 +433,7 @@ def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None,
if dir is None:
dir = gettempdir()
- if 'b' in mode:
- flags = _bin_openflags
- else:
- flags = _text_openflags
+ flags = _bin_openflags
# Setting O_TEMPORARY in the flags causes the OS to delete
# the file when it is closed. This is only supported by Windows.
@@ -475,10 +471,7 @@ else:
if dir is None:
dir = gettempdir()
- if 'b' in mode:
- flags = _bin_openflags
- else:
- flags = _text_openflags
+ flags = _bin_openflags
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
try: