homepage

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 earonesty
Recipients earonesty
Date 2019年07月01日.20:35:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1562013315.01.0.238177593391.issue37477@roundup.psfhosted.org>
In-reply-to
Content
Depending on the user's permissions, this code can hang, instead of raising an exception:
 from tempfile import NamedTemporaryFile
 NamedTemporaryFile(dir="/")
The problamatic code is in tempfile.py:
When encountering a "[Errno 13] Permission denied: '/tmpmcupmo_g'", the current code uses _os.access(dir, _os.W_OK) in two places to check if access is allowed to write to the directory.
On windows, _os.access does not check if the user has permission to write to the folder, it only checks if the folder is read-only (and it doesn't even do a good job at that).
So the temp file creator loops for a rather long time, and consumes a massive amount of system resources, because os.TMP_MAX on modern windows versions is 2147483647.
This article explains how to check if a directory can-write without trying to write to it:
http://blog.aaronballman.com/2011/08/how-to-check-access-rights/
Alternatively, a more careful check of the winerror return value from the open call *might* be sufficient.
History
Date User Action Args
2019年07月01日 20:35:15earonestysetrecipients: + earonesty
2019年07月01日 20:35:15earonestysetmessageid: <1562013315.01.0.238177593391.issue37477@roundup.psfhosted.org>
2019年07月01日 20:35:14earonestylinkissue37477 messages
2019年07月01日 20:35:14earonestycreate

AltStyle によって変換されたページ (->オリジナル) /