MCPcopy Index your code
hub / github.com/python/cpython / mkstemp

Function mkstemp

Lib/tempfile.py:318–354  ·  view source on GitHub ↗

User-callable function to create and return a unique temporary file. The return value is a pair (fd, name) where fd is the file descriptor returned by os.open, and name is the filename. If 'suffix' is not None, the file name will end with that suffix, otherwise there will be no suf

(suffix=None, prefix=None, dir=None, text=False)

Source from the content-addressed store, hash-verified

316 return _os.fsencode(_gettempdir())
317
318def mkstemp(suffix=None, prefix=None, dir=None, text=False):
319 """User-callable function to create and return a unique temporary
320 file. The return value is a pair (fd, name) where fd is the
321 file descriptor returned by os.open, and name is the filename.
322
323 If 'suffix' is not None, the file name will end with that suffix,
324 otherwise there will be no suffix.
325
326 If 'prefix' is not None, the file name will begin with that prefix,
327 otherwise a default prefix is used.
328
329 If 'dir' is not None, the file will be created in that directory,
330 otherwise a default directory is used.
331
332 If 'text' is specified and true, the file is opened in text
333 mode. Else (the default) the file is opened in binary mode.
334
335 If any of 'suffix', 'prefix' and 'dir' are not None, they must be the
336 same type. If they are bytes, the returned name will be bytes; str
337 otherwise.
338
339 The file is readable and writable only by the creating user ID.
340 If the operating system uses permission bits to indicate whether a
341 file is executable, the file is executable by no one. The file
342 descriptor is not inherited by children of this process.
343
344 Caller is responsible for deleting the file when done with it.
345 """
346
347 prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
348
349 if text:
350 flags = _text_openflags
351 else:
352 flags = _bin_openflags
353
354 return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
355
356
357def mkdtemp(suffix=None, prefix=None, dir=None):

Callers

nothing calls this directly

Calls 2

_sanitize_paramsFunction · 0.85
_mkstemp_innerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…