Eryk Sun <eryk...@gmail.com> 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.

Thanks. I hadn't considered that. It can lead to unusual behavior like this 
when __del__ keeps an object alive. The object can't assume that referenced 
objects haven't already been finalized. All of the subsequently required 
instance methods should take this into account. For example, 
Popen._internal_poll could set the return code to -1 if self._handle.closed is 
true. That's at a higher level, and much more reasonable, than trying to handle 
ERROR_INVALID_HANDLE, which could mask bugs.

----------

_______________________________________
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