@@ -33,7 +33,7 @@ is recommended to use keyword arguments for clarity.
3333
3434The module defines the following user-callable items:
3535
36- .. function :: TemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix='' , prefix='tmp' , dir=None)
36+ .. function :: TemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix=None , prefix=None , dir=None)
3737
3838 Return a :term: `file-like object ` that can be used as a temporary storage area.
3939 The file is created securely, using the same rules as :func: `mkstemp `. It will be destroyed as soon
@@ -54,8 +54,8 @@ The module defines the following user-callable items:
5454 stored. *buffering *, *encoding * and *newline * are interpreted as for
5555 :func: `open `.
5656
57- The *dir *, *prefix * and *suffix * parameters have the same meaning
58- as with :func: `mkstemp `.
57+ The *dir *, *prefix * and *suffix * parameters have the same meaning and
58+ defaults as with :func: `mkstemp `.
5959
6060 The returned object is a true file object on POSIX platforms. On other
6161 platforms, it is a file-like object whose :attr: `!file ` attribute is the
@@ -69,7 +69,7 @@ The module defines the following user-callable items:
6969 The :py:data: `os.O_TMPFILE ` flag is now used if available.
7070
7171
72- .. function :: NamedTemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix='' , prefix='tmp' , dir=None, delete=True)
72+ .. function :: NamedTemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix=None , prefix=None , dir=None, delete=True)
7373
7474 This function operates exactly as :func: `TemporaryFile ` does, except that
7575 the file is guaranteed to have a visible name in the file system (on
@@ -84,7 +84,7 @@ The module defines the following user-callable items:
8484 be used in a :keyword: `with ` statement, just like a normal file.
8585
8686
87- .. function :: SpooledTemporaryFile(max_size=0, mode='w+b', buffering=None, encoding=None, newline=None, suffix='' , prefix='tmp' , dir=None)
87+ .. function :: SpooledTemporaryFile(max_size=0, mode='w+b', buffering=None, encoding=None, newline=None, suffix=None , prefix=None , dir=None)
8888
8989 This function operates exactly as :func: `TemporaryFile ` does, except that
9090 data is spooled in memory until the file size exceeds *max_size *, or
@@ -106,7 +106,7 @@ The module defines the following user-callable items:
106106 the truncate method now accepts a ``size `` argument.
107107
108108
109- .. function :: TemporaryDirectory(suffix='' , prefix='tmp' , dir=None)
109+ .. function :: TemporaryDirectory(suffix=None , prefix=None , dir=None)
110110
111111 This function securely creates a temporary directory using the same rules as :func: `mkdtemp `.
112112 The resulting object can be used as a context manager (see
@@ -138,32 +138,29 @@ The module defines the following user-callable items:
138138 Unlike :func: `TemporaryFile `, the user of :func: `mkstemp ` is responsible
139139 for deleting the temporary file when done with it.
140140
141- If *suffix * is specified , the file name will end with that suffix,
141+ If *suffix * is not `` None `` , the file name will end with that suffix,
142142 otherwise there will be no suffix. :func: `mkstemp ` does not put a dot
143143 between the file name and the suffix; if you need one, put it at the
144144 beginning of *suffix *.
145145
146- If *prefix * is specified, the file name will begin with that prefix;
147- otherwise, a default prefix is used.
146+ If *prefix * is not ``None ``, the file name will begin with that prefix;
147+ otherwise, a default prefix is used. The default is the return value of
148+ :func: `gettempprefix ` or :func: `gettempprefixb `, as appropriate.
148149
149- If *dir * is specified , the file will be created in that directory;
150+ If *dir * is not `` None `` , the file will be created in that directory;
150151 otherwise, a default directory is used. The default directory is chosen
151152 from a platform-dependent list, but the user of the application can
152153 control the directory location by setting the *TMPDIR *, *TEMP * or *TMP *
153154 environment variables. There is thus no guarantee that the generated
154155 filename will have any nice properties, such as not requiring quoting
155156 when passed to external commands via ``os.popen() ``.
156157
157- *suffix *, *prefix *, and *dir * must all contain the same type, if specified.
158+ If any of *suffix *, *prefix *, and *dir * are not
159+ ``None ``, they must be the same type.
158160 If they are bytes, the returned name will be bytes instead of str.
159161 If you want to force a bytes return value with otherwise default behavior,
160162 pass ``suffix=b'' ``.
161163
162- A *prefix * value of ``None `` means use the return value of
163- :func: `gettempprefix ` or :func: `gettempprefixb ` as appropriate.
164-
165- A *suffix * value of ``None `` means use an appropriate empty value.
166-
167164 If *text * is specified, it indicates whether to open the file in binary
168165 mode (the default) or text mode. On some platforms, this makes no
169166 difference.
@@ -241,7 +238,7 @@ The module defines the following user-callable items:
241238
242239.. function :: gettempprefixb()
243240
244- Same as :func: `gettempprefixb ` but the return value is in bytes.
241+ Same as :func: `gettempprefix ` but the return value is in bytes.
245242
246243 .. versionadded :: 3.5
247244
@@ -314,8 +311,9 @@ other functions described above.
314311 Use :func: `mkstemp ` instead.
315312
316313 Return an absolute pathname of a file that did not exist at the time the
317- call is made. The *prefix *, *suffix *, and *dir * arguments are the same
318- as for :func: `mkstemp `.
314+ call is made. The *prefix *, *suffix *, and *dir * arguments are similar
315+ to those of :func: `mkstemp `, except that bytes file names, ``suffix=None ``
316+ and ``prefix=None `` are not supported.
319317
320318 .. warning ::
321319
0 commit comments