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 vstinner
Recipients Chip Lynch, efiop, emanuel, eryksun, gregory.p.smith, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Date 2019-09-06.09:13:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567761239.47.0.932416828186.issue37380@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2019-09-06 09:13:59vstinnersetrecipients: + vstinner, gregory.p.smith, paul.moore, tim.golden, zach.ware, eryksun, steve.dower, efiop, emanuel, Chip Lynch
2019-09-06 09:13:59vstinnersetmessageid: <1567761239.47.0.932416828186.issue37380@roundup.psfhosted.org>
2019-09-06 09:13:59vstinnerlinkissue37380 messages
2019-09-06 09:13:59vstinnercreate