Jesús Cea Avión added the comment:

I would catch ALL exceptions, not only "OSError".

An easy way to test this would be to test a subclass of Popen with 
"_execute_child()" method overrided for always raising an exception.

On Unix the test could just open six fds, close them taking note of the values, 
call this code forcing an exception, catch it, open six new fds and verify that 
the numbers are the same. So we verify that neither of the six fds created 
"inside" are leaked.

What should we do for Windows?


Maybe the easier and more portable approach for exception cleanup would be to 
do "_execute_child()" AFTER the "fdopen()" dance, so we can just do "close()" 
if any exception is raised.

Also, the cleanup MUST be done ONLY if the fds were created inside the function 
(PIPE), not if the fd came from the caller.

----------
nosy: +jcea

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

Reply via email to