[issue12623] "universal newlines" subprocess support broken with select- and poll-based communicate()

Martin Panter report at bugs.python.org
Sun Jun 12 03:54:21 EDT 2016


Martin Panter added the comment:

.
Summary: There was originally a bug, but it has been fixed. At best, we leave this open to work on including Andrew’s patch.

Andrew’s patch adds a modified copy of test_universal_newlines_communicate_stdin(). But it does not look correct, and would fail on Windows. It needs to avoid decoding newlines in the child, like in revision 150fa296f5b9. IMO the existing test_universal_newlines_communicate_stdin() test should also be adjusted to verify that os.linesep was sent to the child process.

Also, I don’t understand the SETBINARY business. Aren’t stdin etc set to binary mode by default in Python 3? Yes, it would be required for Python 2 compatibility, but if this patch is only for Python 3, why do we need it?

Anyway, Antoine opened this bug specifically about the “select- and poll-based” implementation (now based on the new selectors module). That implementation is only used with multiple pipes. So I don’t see how the patch is relevant to the original issue (although it may be worthwhile updating and adding anyway).

Regarding Antoine’s original report, we now do encode text strings to bytes. This was fixed as a side effect of revision c4a0fa6e687c in 3.3 (added timeout=... parameter), and directly in 3.2 by Issue 16903.

As for newline translation, I’m not sure if that is really relevant. The selectors implementation is only used if sys.platform != "win32", while os.linesep translation only needs to happen when 'posix' not in sys.builtin_module_names. I suspect in all cases where the selectors implementation is used, and os.linesep is "\n", so it is not actually a bug.

----------
components: +Tests
nosy: +martin.panter
priority: critical -> normal
resolution:  -> out of date
stage: needs patch -> patch review
superseder:  -> subprocess.Popen.communicate with universal_newlines=True doesn't accept strings on 3.2

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


More information about the Python-bugs-list mailing list