Jack O'Connor added the comment:

Related: The asyncio communicate() method differs from standard subprocess in 
how it treats input bytes when stdin is (probably mistakenly) not set to PIPE. 
Like this:

    proc = await create_subprocess_shell("sleep 5")
    await proc.communicate(b"foo")  # Oops, I forgot stdin=PIPE above!

The standard, non-async version of this example, communicate would ignore the 
input bytes entirely. But here in the asyncio version, communicate will try to 
write those bytes to stdin, which is None, and the result is an AttributeError.

Since the user probably only hits this case by mistake, I think raising an 
exception is preferable. But it would be nice to raise an exception that 
explicitly said "you've forgotten stdin=PIPE" instead of the unhelpful 
"'NoneType' object has no attribute 'write'". Maybe it would be worth cleaning 
this up while we're here?

----------

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

Reply via email to