Skip to content

Commit 04490bf

Browse files
committed
tempfile's mkstemp(): Changed last argument from
binary=True to text=False by BDFL Pronouncement. All other changes follow from this. The change to the docs is ready to go, but blocked by another JackMacLock in the doc directory.
1 parent 5c08a99 commit 04490bf

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

Lib/tempfile.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ def gettempdir():
250250
_once('tempdir', _get_default_tempdir)
251251
return tempdir
252252

253-
def mkstemp(suffix="", prefix=template, dir=gettempdir(), binary=True):
254-
"""mkstemp([suffix, [prefix, [dir, [binary]]]])
253+
def mkstemp(suffix="", prefix=template, dir=gettempdir(), text=False):
254+
"""mkstemp([suffix, [prefix, [dir, [text]]]])
255255
User-callable function to create and return a unique temporary
256256
file. The return value is a pair (fd, name) where fd is the
257257
file descriptor returned by os.open, and name is the filename.
@@ -265,9 +265,9 @@ def mkstemp(suffix="", prefix=template, dir=gettempdir(), binary=True):
265265
If 'dir' is specified, the file will be created in that directory,
266266
otherwise a default directory is used.
267267
268-
If 'binary' is specified and false, the file is opened in text
269-
mode. Otherwise, the file is opened in binary mode. On some
270-
operating systems, this makes no difference.
268+
If 'text' is specified and true, the file is opened in text
269+
mode. Else (the default) the file is opened in binary mode. On
270+
some operating systems, this makes no difference.
271271
272272
The file is readable and writable only by the creating user ID.
273273
If the operating system uses permission bits to indicate whether a
@@ -277,10 +277,10 @@ def mkstemp(suffix="", prefix=template, dir=gettempdir(), binary=True):
277277
Caller is responsible for deleting the file when done with it.
278278
"""
279279

280-
if binary:
281-
flags = _bin_openflags
282-
else:
280+
if text:
283281
flags = _text_openflags
282+
else:
283+
flags = _bin_openflags
284284

285285
return _mkstemp_inner(dir, prefix, suffix, flags)
286286

@@ -290,7 +290,7 @@ def mkdtemp(suffix="", prefix=template, dir=gettempdir()):
290290
User-callable function to create and return a unique temporary
291291
directory. The return value is the pathname of the directory.
292292
293-
Arguments are as for mkstemp, except that the 'binary' argument is
293+
Arguments are as for mkstemp, except that the 'text' argument is
294294
not accepted.
295295
296296
The directory is readable, writable, and searchable only by the
@@ -319,7 +319,7 @@ def mktemp(suffix="", prefix=template, dir=gettempdir()):
319319
User-callable function to return a unique temporary file name. The
320320
file is not created.
321321
322-
Arguments are as for mkstemp, except that the 'binary' argument is
322+
Arguments are as for mkstemp, except that the 'text' argument is
323323
not accepted.
324324
325325
This function is unsafe and should not be used. The file name

Lib/test/test_pkg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def runtest(hier, code):
5656
root = tempfile.mkdtemp()
5757
mkhier(root, hier)
5858
savepath = sys.path[:]
59-
fd, fname = tempfile.mkstemp(binary=False)
59+
fd, fname = tempfile.mkstemp(text=True)
6060
os.write(fd, code)
6161
os.close(fd)
6262
try:

0 commit comments

Comments
 (0)