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.
This commit is contained in:
Tim Peters 2002-08-14 15:41:26 +00:00
parent 5c08a99b77
commit 04490bf225
2 changed files with 11 additions and 11 deletions

View File

@ -250,8 +250,8 @@ def gettempdir():
_once('tempdir', _get_default_tempdir) _once('tempdir', _get_default_tempdir)
return tempdir return tempdir
def mkstemp(suffix="", prefix=template, dir=gettempdir(), binary=True): def mkstemp(suffix="", prefix=template, dir=gettempdir(), text=False):
"""mkstemp([suffix, [prefix, [dir, [binary]]]]) """mkstemp([suffix, [prefix, [dir, [text]]]])
User-callable function to create and return a unique temporary User-callable function to create and return a unique temporary
file. The return value is a pair (fd, name) where fd is the file. The return value is a pair (fd, name) where fd is the
file descriptor returned by os.open, and name is the filename. file descriptor returned by os.open, and name is the filename.
@ -265,9 +265,9 @@ def mkstemp(suffix="", prefix=template, dir=gettempdir(), binary=True):
If 'dir' is specified, the file will be created in that directory, If 'dir' is specified, the file will be created in that directory,
otherwise a default directory is used. otherwise a default directory is used.
If 'binary' is specified and false, the file is opened in text If 'text' is specified and true, the file is opened in text
mode. Otherwise, the file is opened in binary mode. On some mode. Else (the default) the file is opened in binary mode. On
operating systems, this makes no difference. some operating systems, this makes no difference.
The file is readable and writable only by the creating user ID. The file is readable and writable only by the creating user ID.
If the operating system uses permission bits to indicate whether a If the operating system uses permission bits to indicate whether a
@ -277,10 +277,10 @@ def mkstemp(suffix="", prefix=template, dir=gettempdir(), binary=True):
Caller is responsible for deleting the file when done with it. Caller is responsible for deleting the file when done with it.
""" """
if binary: if text:
flags = _bin_openflags
else:
flags = _text_openflags flags = _text_openflags
else:
flags = _bin_openflags
return _mkstemp_inner(dir, prefix, suffix, flags) return _mkstemp_inner(dir, prefix, suffix, flags)
@ -290,7 +290,7 @@ def mkdtemp(suffix="", prefix=template, dir=gettempdir()):
User-callable function to create and return a unique temporary User-callable function to create and return a unique temporary
directory. The return value is the pathname of the directory. directory. The return value is the pathname of the directory.
Arguments are as for mkstemp, except that the 'binary' argument is Arguments are as for mkstemp, except that the 'text' argument is
not accepted. not accepted.
The directory is readable, writable, and searchable only by the The directory is readable, writable, and searchable only by the
@ -319,7 +319,7 @@ def mktemp(suffix="", prefix=template, dir=gettempdir()):
User-callable function to return a unique temporary file name. The User-callable function to return a unique temporary file name. The
file is not created. file is not created.
Arguments are as for mkstemp, except that the 'binary' argument is Arguments are as for mkstemp, except that the 'text' argument is
not accepted. not accepted.
This function is unsafe and should not be used. The file name This function is unsafe and should not be used. The file name

View File

@ -56,7 +56,7 @@ def runtest(hier, code):
root = tempfile.mkdtemp() root = tempfile.mkdtemp()
mkhier(root, hier) mkhier(root, hier)
savepath = sys.path[:] savepath = sys.path[:]
fd, fname = tempfile.mkstemp(binary=False) fd, fname = tempfile.mkstemp(text=True)
os.write(fd, code) os.write(fd, code)
os.close(fd) os.close(fd)
try: try: