This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kichik
Recipients kichik
Date 2012-12-28.05:37:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
tempfile._get_default_tempdir() tries to find a good temporary directory by attempting to create a file and write a string into it for all candidate directories. It deletes those files right after closing them. But if writing rather than creating them fails, the files get left behind. This can happen, for example, when the disk is full on Linux. It will let you create the file with open() and even write() to it. But as soon as close() is called, OSError is raised with errno 28 (No space left on device) and unlink() is never called.

On our system (Linux 2.6.32, ext3), after filling the disk by mistake, we suddenly found dozens of random empty files scattered across the file system. The candidate list, where they were all found, even includes the root directory so the issue is quite visible.

We noticed this problem on Python 2.4.4, but I have been able to reproduce it with today's tip.

A possible solution would be wrapping everything between open() and unlink() in a try-finally block. This way, no matter what happens, the file will get deleted. I have attached a patch implementing this solution and a new test case that reproduces the issue. Verified with `make test && make patchcheck`.
Date User Action Args
2012-12-28 05:37:38kichiksetrecipients: + kichik
2012-12-28 05:37:37kichiksetmessageid: <>
2012-12-28 05:37:37kichiklinkissue16800 messages
2012-12-28 05:37:36kichikcreate