summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
Commit message (Collapse)AuthorAgeFilesLines
* Record that FCNTL.py has gone away; remove FCNTL hack in tempfile.py;Tim Peters2004-07-181-7/+5
| | | | | another hack remains in test___all__.py, but the problem that one addresses is more general than *just* FCNTL, so leaving it alone.
* mktemp() shouldn't rely on os.path.exists(), which can return False ifGuido van Rossum2003-11-101-1/+23
| | | | | the file is a symlink. Instead, use os.lstat directly, if it exists; fall back on os.stat or the built-in open. Thanks to Iustin Pop.
* fixed wrong error checking on fcntl call as per SF bug # 821896Alex Martelli2003-11-091-2/+3
| | | | (same as commit of Sun Nov 2 to the release23-maint branch)
* Patch #810914: Return absolute path for mkstemp. Fixes #810408.Martin v. Löwis2003-10-121-1/+1
| | | | | This should not be backported to 2.3, as it might break backwards compatibility.
* Windows fix: When PYTHONCASEOK is set, or for any other reason importsTim Peters2003-07-221-3/+9
| | | | | | | | | | are satisfied in a case-insensitive manner, the attempt to import (the non-existent) fcntl gets satisfied by FCNTL.py instead, and the tempfile module defines a Unix-specific _set_cloexec() function in that case. As a result, temp files can't be created then (blows up with an AttributeError trying to reference fcntl.fcntl). This just popped up in the spambayes project, where there is no apparent workaround (which is why I'm pushing this in now).
* Getting rid of macfs.Jack Jansen2003-03-211-6/+6
|
* Use the dummy_thread module in Queue.py and tempfile.py.Guido van Rossum2002-12-301-6/+3
| | | | | tempfile.py already contained code to let it run without threads present; for Queue.py this is considered a useful feature too.
* Comment out the warnings about mktemp(). These are too annoying, andGuido van Rossum2002-11-221-3/+3
| | | | often unavoidable.
* _RandomNameSequence(): style guide changes, small speedup, don'tTim Peters2002-11-211-8/+8
| | | | | put more in the critical section than absolutely needed, acquire the mutex before the "try".
* _TemporaryFileWrapper: changed self.close_called to a proper bool.Tim Peters2002-11-211-2/+2
|
* Get rid of _once(); inlining it takes less code. :-)Guido van Rossum2002-08-171-36/+41
| | | | | | | Also, don't call gettempdir() in the default expression for the 'dir' argument to various functions; use 'dir=None' for the default and insert 'if dir is None: dir = gettemptir()' in the bodies. That way the work done by gettempdir is postponed until needed.
* tempfile's mkstemp(): Changed last argument fromTim Peters2002-08-141-10/+10
| | | | | | | | | | 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.
* Patch #595014: Cygwin tempfile patchJason Tishler2002-08-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Although Cygwin attempts to be as Posix compliant as possible, it has difficulties unlinking open files. This is not surprising given that Cygwin is dependent on Win32 which in turn has this problem itself. The attached tempfile patch acknowledges this Cygwin limitation. Without this patch, Cygwin fails test_tempfile (i.e., test_has_no_name) as follows: $ ./python -E -tt ../Lib/test/regrtest.py -l test_tempfile test_tempfile test test_tempfile failed -- Traceback (most recent call last): File "/home/jt/src/PythonCvs/Lib/test/test_tempfile.py", line 689, in test_has_no_name self.failOnException("rmdir", ei) File "/home/jt/src/PythonCvs/Lib/test/test_tempfile.py", line 33, in failOnException self.fail("%s raised %s: %s" % (what, ei[0], ei[1])) File "/home/jt/src/PythonCvs/Lib/unittest.py", line 260, in fail raise self.failureException, msg AssertionError: rmdir raised exceptions.OSError: [Errno 90] Directory not empty: '/mnt/c/DOCUME~1/jatis/LOCALS~1/Temp/tmpM_z8nj'
* mkstemp(): Repaired error in docstring (the sense of the 'binary' flagTim Peters2002-08-141-2/+2
| | | | was reversed).
* mkstemp(): The optional "binary" argument is clearly intended to be aTim Peters2002-08-131-1/+1
| | | | Boolean, so changed its default value from 1 to True.
* NamedTemporaryFile(), TemporaryFile(): removed needless local vrbl 'bin'.Tim Peters2002-08-131-6/+8
|
* template: removed special-casing for NT; there isn't an 8-character limit.Tim Peters2002-08-131-4/+1
|
* _once(): Removed obfuscating aliasing of _once_lock.Tim Peters2002-08-131-4/+2
|
* _once(): Simplified dict manipulation.Tim Peters2002-08-131-2/+2
|
* Whitespace normalization.Tim Peters2002-08-091-6/+9
|
* Check-in of the most essential parts of SF 589982 (tempfile.pyGuido van Rossum2002-08-091-225/+396
| | | | | | | | rewrite, by Zack Weinberg). This replaces most code in tempfile.py (please review!!!) and adds extensive unit tests for it. This will cause some warnings in the test suite; I'll check those in soon, and also the docs.
* SF 563203. Replaced 'has_key()' with 'in'.Raymond Hettinger2002-06-011-1/+1
|
* If possible, set FD_CLOEXEC flag on file descriptors opened usingNeil Schemenauer2002-03-241-0/+12
| | | | TemporaryFile. This flag causes the fd to be closed on exec().
* Thanks to Detlef Lannert for pointing out a typo in the code thatTim Peters2002-01-301-1/+1
| | | | uses _DummyMutex on platforms without threads.
* New TemporaryFile implementation for Windows: this doesn't need aTim Peters2002-01-301-1/+17
| | | | | | | | | | | TemproraryFileWrapper wrapper anymore, and should be immune from the problem that a temp file inherited by a spawned process caused an attempt to close the temp file in the spawning process to blow up (the unlink in TemporaryFileWrapper.close() blew up with a "Permission denied" error because, despite that the temp file got closed in the spawning process, the spawned process still had it open by virtue of C-level file descriptor inheritance). In context, that bug took days to figure out <wink/sigh>.
* SF bug #509805 tempfile.gettempdir not threadsafeTim Peters2002-01-281-2/+28
| | | | | | | | | | | | | | | This is an ancient race when multiple threads call gettempdir() (or anything relying on it) for the first time. Fixed x-platform via the Big Hammer of rearranging the code to serialize the first calls. Subsequent calls are as fast as before. Note that the Python test suite can't provoke this bug: it requires setting up multiple threads making the very first calls into tempfile, but the test suite uses tempfile several times before getting to test_threadedtempfile. Bugfix candidate.
* TemporaryFileWrapper: fixed typo in new comment.Tim Peters2001-12-181-1/+1
|
* TemporaryFileWrapper: cache the value of os.unlink for use by __del__,Tim Peters2001-12-181-1/+8
| | | | | to prevent mysterious errors at shutdown due to "os.unlink" turning into "None.unlink".
* SF bug #476138: tempfile behavior across platformsTim Peters2001-10-291-4/+6
| | | | | Ensure that a tempfile can be closed any number of times without error. This wasn't true on Windows.
* SF patch #474590 -- RISC OS supportGuido van Rossum2001-10-241-1/+5
|
* Search /tmp before /var/tmp and /usr/tmp -- this seems preferred.Guido van Rossum2001-03-021-1/+1
| | | | SF patch #404564, Gregor Hoffleit.
* final round of __all__ lists (I hope) - skipped urllib2 because Moshe may beSkip Montanaro2001-03-011-0/+2
| | | | giving it a slight facelift
* fix long lineJeremy Hylton2001-02-191-1/+2
|
* Whitespace normalization.Tim Peters2001-01-151-25/+25
|
* Reverting a dumb experimental version I checked in by mistake.Tim Peters2001-01-141-9/+2
|
* SF bug 128713: type(mmap_object) blew up on Linux.Tim Peters2001-01-141-2/+9
|
* Guido found a brand new race in tempfile on Linux, due to Linux changingTim Peters2001-01-131-16/+31
| | | | | | | | | | | | pid across threads (but in that case, it's still the same process, and so still sharing the "template" cache in tempfile.py). Repaired that, and added a new std test. On Linux, someone please run that standalone with more files and/or more threads; e.g., python lib/test/test_threadedtempfile.py -f 1000 -t 10 to run with 10 threads each creating (and deleting) 1000 temp files.
* A variant of SF patch 103028 (Make tempfile.mktemp threadsafe).Tim Peters2001-01-121-12/+45
| | | | | | | Tested on Windows. Should be tested on Linux. Should also be tested on some platform without threads (I simulated that by making the "import thread" fail, but that's not the same as actually doing it!).
* Patch by tg@FreeBSD.org to try /var/tmp first.Guido van Rossum2000-08-291-1/+1
| | | | This helps on 4.4BSD-based systems.
* Security patch for Unix by Chris McDonough.Guido van Rossum2000-04-241-7/+21
| | | | | | This uses the same precautions when trying to find a temporary directory as when the actual tempfile is created (using O_CREAT and O_EXCL). On non-posix platforms, nothing is changed.
* The third and final doc-string sweep by Ka-Ping Yee.Guido van Rossum2000-02-041-8/+6
| | | | | | | | The attached patches update the standard library so that all modules have docstrings beginning with one-line summaries. A new docstring was added to formatter. The docstring for os.py was updated to mention nt, os2, ce in addition to posix, dos, mac.
* In class TemporaryFileWrapper, don't cache attributes of tpye int --Guido van Rossum1999-06-011-1/+2
| | | | | | these happen to be 'closed' and 'softspace', which may change! Noted by Dave Ascher (with slightly different solution).
* Improvement to the previous fix suggested by Thomas Bellman: if theGuido van Rossum1998-10-241-2/+6
| | | | | unlink() or fdopen() fail, close the file descriptor and re-raise the exception.
* The TemporaryFile() function has a security leak -- because theGuido van Rossum1998-10-241-5/+6
| | | | | | | | | | | | | filenames generated are easily predictable, it is possible to trick an unsuspecting program into overwriting another file by creating a symbolic link with the predicted name. Fix this by using the low-level os.open() function with the O_EXCL flag and mode 0700. On non-Unix platforms, presumably there are no symbolic links so the problem doesn't exist. The explicit test for Unix (posix, actually) makes it possible to change the non-Unix logic to work without a try-except clause. The mktemp() file is as unsafe as ever.
* Fix so that after a fork() -- on Unix only -- the template getsGuido van Rossum1998-10-141-3/+9
| | | | recalculated.
* On the Mac, create the Temporary Items folder if it does not exist yet.Guido van Rossum1998-04-281-1/+1
| | | | (Jack)
* When getcwd() doesn't exist or raises an exception, don't fail butGuido van Rossum1998-04-091-1/+5
| | | | | fall back to using os.curdir instead; if it is fine, don't use os.curdir at all.
* Mass check-in after untabifying all files that need it.Guido van Rossum1998-03-261-58/+58
|
* Add new optional parameter 'suffix' (default ''), which is appended toGuido van Rossum1997-12-191-10/+11
| | | | the temporary file name. Also some minor formatting of Jim F's code.
* On NT, use a better template, ~XXX- where XXX is os.getpid().Guido van Rossum1997-12-151-0/+2
|