[Python-Dev] A question about the subprocess implementation

Phil Vandry vandry at TZoNE.ORG
Sun Jan 8 03:28:56 CET 2012


On 2012-01-08 10:48 , Vinay Sajip wrote:
> Terry Reedy<tjreedy<at>  udel.edu>  writes:
>> The behavior matches the doc: Popen.stdin
>> If the stdin argument was PIPE, this attribute is a file object that
>> provides input to the child process. Otherwise, it is None.
>
> Right, but it's not very helpful, nor especially intuitive. Why does it have to
> be None in the case where you pass in a file object? Is there some benefit to be
> gained by doing this? Does something bad happen if you store that file object in
> proc.stdin / proc.stdout / proc.stderr?

proc.stdin, proc.stdout, and proc.stderr aren't meant to be a reference 
to the file that got connected to the subprocess' stdin/stdout/stderr. 
They are meant to be a reference to the OTHER END of the pipe that got 
connected. When you pass in a normal file object there is no such thing 
as the OTHER END of that file. The value None reflects this fact, and 
should continue to do so.

-Phil


More information about the Python-Dev mailing list