[New-bugs-announce] [issue33339] Using default encoding with `subprocess.run()` is not obvious

Pekka Klärck report at bugs.python.org
Mon Apr 23 04:38:32 EDT 2018

New submission from Pekka Klärck <pekka.klarck at gmail.com>:

It is possible to use `subprocess.run()` with the system's default encoding by using `universal_newlines=True`. This is very handy, but it's not at all obvious (at least for me) that setting such option has effect on encoding. This is especially true when the docs don't explain this explicitly:

"""If encoding or errors are specified, or universal_newlines is true, file objects for stdin, stdout and stderr are opened in text mode using the specified encoding and errors or the io.TextIOWrapper default."""

This is such a useful feature that it ought to be documented better, preferably with an example.

>From code reading point of view, I would also consider `encoding=True` to be more explicit that `universal_newlines=True`. I can submit a separate issue about that if others feel the same.

messages: 315652
nosy: pekka.klarck
priority: normal
severity: normal
status: open
title: Using default encoding with `subprocess.run()` is not obvious

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list