summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-58451: Add optional delete_on_close parameter to NamedTemporaryFile ↵Ev2geny2022-10-041-36/+40
| | | | (GH-97015)
* gh-83499: Fix closing file descriptors in tempfile (GH-93874)Serhiy Storchaka2022-06-261-28/+51
|
* gh-70363: Implement `io.IOBase` interface for `SpooledTemporaryFile` (GH-29560)Carey Metcalfe2022-05-031-3/+34
| | | | | | | | | | | | | | | | Since the underlying file-like objects (either `io.BytesIO`, or a true file object) all implement the `io.IOBase` interface, the `SpooledTemporaryFile` should as well. Additionally, since the underlying file object will either be an instance of an `io.BufferedIOBase` (for binary mode) or an `io.TextIOBase` (for text mode), methods for these classes were also implemented. In every case, the required methods and properties are simply delegated to the underlying file object. Co-authored-by: Gary Fernie <Gary.Fernie@skyscanner.net> Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* bpo-45192: Fix a bug that infers the type of an os.PathLike[bytes] object as ↵Kyungmin Lee2021-10-201-0/+4
| | | | | | | | | str (GH-28323) An object implementing the os.PathLike protocol can represent a file system path as a str or bytes object. Therefore, _infer_return_type function should infer os.PathLike[str] object as str type and os.PathLike[bytes] object as bytes type.
* bpo-4928: Document NamedTemporaryFile non-deletion after SIGKILL (#26198)Catherine Devlin2021-05-191-0/+4
| | | | | | | * bpo-4928 Document NamedTemporaryFile non-deletion after SIGKILL * 📜🤖 Added by blurb_it. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481)Inada Naoki2021-03-291-0/+7
| | | | | | | | | | | See [PEP 597](https://www.python.org/dev/peps/pep-0597/). * Add `-X warn_default_encoding` and `PYTHONWARNDEFAULTENCODING`. * Add EncodingWarning * Add io.text_encoding() * open(), TextIOWrapper() emits EncodingWarning when encoding is omitted and warn_default_encoding is enabled. * _pyio.TextIOWrapper() uses UTF-8 as fallback default encoding used when failed to import locale module. (used during building Python) * bz2, configparser, gzip, lzma, pathlib, tempfile modules use io.text_encoding(). * What's new entry
* bpo-29982: Add "ignore_cleanup_errors" param to ↵CAM Gerlach2021-03-141-10/+14
| | | | tempfile.TemporaryDirectory() (GH-24793)
* bpo-40701: tempfile mixes str and bytes in an inconsistent manner (GH-20442)Eric L2021-03-031-8/+16
| | | | | | | | | | | The case of tempfile.tempdir variable being bytes is now handled consistently. The getters return the right type and no more error of mixing str and bytes unless explicitly caused by the user. Adds a regression test. Expands the documentation to clarify the behavior. Co-authored-by: Eric L <ewl+git@lavar.de> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* tempfile: Use random.choises() instead of choise() (GH-23068)Inada Naoki2020-11-011-4/+1
|
* Revert "bpo-42160: tempfile: Reduce overhead of pid check. (GH-22997)"Inada Naoki2020-10-311-10/+12
| | | | | `_RandomNameSequence` is not true singleton so using `os.register_at_fork` doesn't make sense unlike `random._inst`. This reverts commit 8e409cebad42032bb7d0f2cadd8b1e36081d98af.
* bpo-42160: tempfile: Reduce overhead of pid check. (GH-22997)Eric W2020-10-301-12/+10
| | | | The _RandomSequence class in tempfile used to check the current pid every time its rng property was used. This commit replaces this code with `os.register_at_fork` to reduce the overhead.
* bpo-41410: Fix outdated info in mkstemp docs (GH-21701)Rishav Kundu2020-08-141-2/+1
| | | Automerge-Triggered-By: @ericvsmith
* bpo-40287: Fix SpooledTemporaryFile.seek() return value (GH-19540)Inada Naoki2020-04-171-1/+1
| | | It has not returned the file position after the seek.
* bpo-39481: PEP 585 for a variety of modules (GH-19423)Batuhan Taşkaya2020-04-101-0/+2
| | | | | | | | | | - concurrent.futures - ctypes - http.cookies - multiprocessing - queue - tempfile - unittest.case - urllib.parse
* bpo-39481: Implementation for PEP 585 (#18239)Guido van Rossum2020-04-071-11/+2
| | | | | | | | | | | | This implements things like `list[int]`, which returns an object of type `types.GenericAlias`. This object mostly acts as a proxy for `list`, but has attributes `__origin__` and `__args__` that allow recovering the parts (with values `list` and `(int,)`. There is also an approximate notion of type variables; e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`. Type variables are objects of type `typing.TypeVar`.
* bpo-39719: Remove softspace from tempfile.SpooledTemporaryFile (GH-18599)Shantanu2020-03-171-4/+0
|
* bpo-39019: Implement missing __class_getitem__ for SpooledTemporaryFile ↵Batuhan Taşkaya2019-12-301-0/+12
| | | | | | (GH-17560)
* bpo-26730: Fix SpooledTemporaryFile data corruption (GH-17400)Inada Naoki2019-11-271-6/+9
| | | | | | | SpooledTemporaryFile.rollback() might cause data corruption when it is in text mode. Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
* bpo-37363: Add audit events for a range of modules (GH-14301)Steve Dower2019-06-241-1/+4
|
* bpo-26660, bpo-35144: Fix permission errors in TemporaryDirectory cleanup. ↵Serhiy Storchaka2019-05-311-2/+32
| | | | | | | (GH-10320) TemporaryDirectory.cleanup() failed when non-writeable or non-searchable files or directories were created inside a temporary directory.
* Clean up code which checked presence of os.{stat,lstat,chmod} (#11643)Anthony Sottile2019-02-251-11/+1
|
* bpo-27300: Add the errors parameter to tempfile classes. (GH-6696)sth2018-05-231-19/+16
|
* bpo-33522: Enable CI builds on Visual Studio Team Services (#6865)Steve Dower2018-05-161-1/+3
|
* Update docstring of tempfile._RandomNameSequence (GH-6414)Wolfgang Maier2018-04-091-1/+1
| | | | | When bpo-12015 got resolved by increasing the length of the random string generated by _RandomNameSequence from six to eight characters, the docstring of the class was not adjusted accordingly.
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-5/+1
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-30030: Revert f50354ad (tempfile) (#1187)Victor Stinner2017-04-191-12/+23
| | | | Revert f50354adaaafebe95ad09d09b825804a686ea843: it introduced a regression in test_threadedtempfile.
* Reimplement tempfile._RandomNameSequence using a generator function. (#1075)Serhiy Storchaka2017-04-111-23/+12
|
* Add a source parameter to warnings.warn()Victor Stinner2016-03-221-1/+0
| | | | | | | | Issue #26604: * Add a new optional source parameter to _warnings.warn() and warnings.warn() * Modify asyncore, asyncio and _pyio modules to set the source parameter when logging a ResourceWarning warning
* Issue #26385: Cleanup NamedTemporaryFile if open() fails, by SilentGhostMartin Panter2016-02-281-1/+2
|
* Issue #26261: Clarify NamedTemporaryFile name attribute vs file.nameMartin Panter2016-02-221-2/+2
|
* Issue #25064: Adjust documentation according to new mkstemp signatureMartin Panter2015-11-071-8/+9
| | | | | | | | The mkstemp() and mkdtemp() signatures have already been updated, but the higher-level functions still suggest that the default values are forced to text strings. Also merged some paragraphs describing the "suffix" and "prefix" parameters, and pointed out that mktemp() does not support the new changes.
* Issue #21515: Elaborate tempfile.TemporaryFile() commentVictor Stinner2015-10-201-2/+10
| | | | | Explain why calling os.open() with os.O_TMPFILE is a safe test to check if O_TMPFILE is supported by the running kernel.
* Issue 24230: The tempfile module now accepts bytes for prefix, suffix and dirGregory P. Smith2015-05-221-26/+89
| | | | parameters and returns bytes in such situations (matching the os module APIs).
* Issue #22107: tempfile.gettempdir() and tempfile.mkdtemp() now try againSerhiy Storchaka2015-05-191-1/+17
|\ | | | | | | | | | | when a directory with the chosen name already exists on Windows as well as on Unix. tempfile.mkstemp() now fails early if parent directory is not valid (not exists or is a file) on Windows.
| * Issue #22107: tempfile.gettempdir() and tempfile.mkdtemp() now try againSerhiy Storchaka2015-05-191-1/+17
| | | | | | | | | | | | when a directory with the chosen name already exists on Windows as well as on Unix. tempfile.mkstemp() now fails early if parent directory is not valid (not exists or is a file) on Windows.
* | Issue #23865: close() methods in multiple modules now are idempotent and moreSerhiy Storchaka2015-04-101-3/+5
|\ \ | |/ | | | | | | robust at shutdown. If needs to release multiple resources, they are released even if errors are occured.
| * Issue #23865: close() methods in multiple modules now are idempotent and moreSerhiy Storchaka2015-04-101-3/+5
| | | | | | | | | | robust at shutdown. If needs to release multiple resources, they are released even if errors are occured.
* | Merge: #23700: fix/improve commentR David Murray2015-03-221-2/+4
|\ \ | |/
| * #23700: fix/improve commentR David Murray2015-03-221-2/+4
| |
* | Issue #23700: NamedTemporaryFile iterator closed underlied file object inSerhiy Storchaka2015-03-201-3/+5
|\ \ | |/ | | | | | | | | some circunstances while NamedTemporaryFile object was living. This causes failing test_csv. Changed the implementation of NamedTemporaryFile.__iter__ to make tests passed.
| * Issue #23700: NamedTemporaryFile iterator closed underlied file object inSerhiy Storchaka2015-03-201-3/+5
| | | | | | | | | | | | some circunstances while NamedTemporaryFile object was living. This causes failing test_csv. Changed the implementation of NamedTemporaryFile.__iter__ to make tests passed.
* | Issue #23700: Iterator of NamedTemporaryFile now keeps a reference toSerhiy Storchaka2015-03-191-1/+3
|\ \ | |/ | | | | NamedTemporaryFile instance. Patch by Bohuslav Kabrda.
| * Issue #23700: Iterator of NamedTemporaryFile now keeps a reference toSerhiy Storchaka2015-03-191-1/+3
| | | | | | | | NamedTemporaryFile instance. Patch by Bohuslav Kabrda.
| * tempfile: Fix docstring. Issue #21397, patch by R. David Murray.Yury Selivanov2014-09-261-5/+5
| |
* | tempfile: Fix docstring. Issue #21397, patch by R. David Murray.Yury Selivanov2014-09-261-5/+5
| |
* | Issue #22427: TemporaryDirectory no longer attempts to clean up twice whenSerhiy Storchaka2014-09-241-12/+3
|\ \ | |/ | | | | used in the with statement in generator.
| * Issue #22427: TemporaryDirectory no longer attempts to clean up twice whenSerhiy Storchaka2014-09-241-12/+3
| | | | | | | | used in the with statement in generator.
* | Issue #21515: Fix typo in a comment, thanks Arfrever for the reportVictor Stinner2014-06-081-1/+1
| |
* | Issue #21515: tempfile.TemporaryFile now uses os.O_TMPFILE flag is availableVictor Stinner2014-06-051-0/+26
|/
* Issue #21058: Fix a leak of file descriptor in tempfile.NamedTemporaryFile(),Victor Stinner2014-03-251-3/+7
| | | | close the file descriptor if io.open() fails