popen python subprocess_issue 12695: subprocess.Popen: OSError: [Errno 9] Bad file descriptor - Pyth...

suprocess.Popen on POSIX (using _posixsubprocess Module) has a good chance of repeatedly closing the same file descriptor if the descriptor for stdin is also used for stdout and/or stderr. Only stdout and stderr are checked for equality with one another.

This breaks webbrowser.open for me, as the browser remote has all three descriptors redirected from/to /dev/null. This breaks "pydoc -p". I've taken this scenario and turned it into a unit test, which you find attached together with a proposed fix.

On my currently installed Python 3.2, the unit tests results in this traceback (and two more like it for other test classes):

ERROR: test_inouterr_fileobj (__main__.ProcessTestCase)

----------------------------------------------------------------------

Traceback (most recent call last):

File "Lib/test/test_subprocess.py", line 630, in test_inouterr_fileobj

stderr = devnull)

File "/usr/lib64/python3.2/subprocess.py", line 736, in __init__

restore_signals, start_new_session)

File "/usr/lib64/python3.2/subprocess.py", line 1330, in _execute_child

raise child_exception_type(errno_num, err_msg)

OSError: [Errno 9] Bad file descriptor

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值