STINNER Victor <vstin...@python.org> added the comment:

> When a Popen instance is finalized by the garbage collector, the internal 
> handle is also finalized and closed despite the instance being put on the 
> active list. This results in _cleanup throwing because the handle can no 
> longer be used.

Right, that's a more practical case where this bug still occurs on Python 3.8 
and older. I would suggest to fix applications which should get a 
ResourceWarning warning in this case.

Chip Lynch wrote me an email saying that his team is impacted by the bug on 
Windows with Python 3.7.

I tried to write a simpler patch ignoring ERROR_INVALID_HANDLE, but then I read 
again this issue discussion: Eryk Sun and me agree that ignorning 
ERROR_INVALID_HANDLE is a bad idea, it can be worse: silence a real bug.

So I now agree to backport the fix from master to 3.7 and 3.8 branches.

I prefer to leave 2.7 unchanged even if it's affected. I don't want to take the 
risk of introducing another regression in 2.7. Moreover, subprocess.Popen has a 
__del__() method. Python 2.7 handles reference cycles differently than Python 
3: it doesn't implement finalizers (PEP 442). While Python 2.7 might be 
affected, it should be affected differently.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37380>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to