[issue37477] NamedTemporaryFile can hang on windows

2019-07-01 Thread Martin Panter


Change by Martin Panter :


--
resolution:  -> duplicate
superseder:  -> tempfile module misinterprets access denied error on Windows

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37477] NamedTemporaryFile can hang on windows

2019-07-01 Thread Erik Aronesty


Erik Aronesty  added the comment:

yes, duplicate of https://bugs.python.org/issue22107 ... tried looking first, 
sry.

--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37477] NamedTemporaryFile can hang on windows

2019-07-01 Thread Martin Panter


Martin Panter  added the comment:

Perhaps a duplicate of Issue 22107?

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37477] NamedTemporaryFile can hang on windows

2019-07-01 Thread Erik Aronesty


Change by Erik Aronesty :


--
type:  -> crash

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37477] NamedTemporaryFile can hang on windows

2019-07-01 Thread Erik Aronesty


New submission from Erik Aronesty :

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.

--
messages: 347073
nosy: earonesty
priority: normal
severity: normal
status: open
title: NamedTemporaryFile can hang on windows
versions: Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com