[New-bugs-announce] [issue15649] subprocess.Popen.communicate: accept str for input parameter if universal_newlines is False

Andrew Svetlov report at bugs.python.org
Tue Aug 14 17:47:01 CEST 2012


New submission from Andrew Svetlov:

Currently Popen.communicate accept str is universal_newlines==True and bytes if universal_newlines==False.

I like to accept both str and bytes if universal_newlines is False and raise explicit exception for bytes if universal_newlines is True.

Looks like universal_newlines for bytes doesn't make sense, also we prefer to use str everywhere. Bytes should be used if it is really byte-stream or if unicode cannot be passed by some limitations of underlying OS etc.

There are couple dark corners:
1. What to do if stdin doesn't have `encoding` attribute? Convert to bytes using filesystemencoding? Raise explicit exception? Adding `encode` parameter for .communicate doesn't looks elegant.
2. How .communicate works on Windows? I see completely different implementation of this method for win32.

----------
messages: 168207
nosy: asvetlov
priority: normal
severity: normal
stage: needs patch
status: open
title: subprocess.Popen.communicate: accept str for input parameter if universal_newlines is False
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15649>
_______________________________________


More information about the New-bugs-announce mailing list