This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author andrewclegg
Recipients andrewclegg, ncoghlan, steve.dower
Date 2017-10-11.10:16:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Following on from

The subprocess module by default returns bytes from subprocess calls. It has a text mode, but this can only be accessed by slightly tangential arguments (setting encoding, errors or universal_newlines).

ncoghlan notes in msg304118 that this is a similar situation to the binary/text mode settings for open(). From the docs " In text mode, if encoding is not specified the encoding used is platform dependent: locale.getpreferredencoding(False) is called to get the current locale encoding"

The universal_newlines argument now effectively just turns on the text mode, however this is not an intuitively and obviously discoverable. So to improve usability, and to mirror the file opening behaviour, subprocess calls should be *explicitly* dual mode (binary/text), and have an explicitly named argument to control this.

My enhancement suggestion is as follows:
* Add a text=True/False argument that is an alias of universal_newlines, to improve the API.
* Clearly document that this implies that the encoding will be guessed, and that an explicit encoding can be given if the guess is wrong

For completeness, the following changes could also be made, although these may be controversial
* Remove/deprecate the universal_newlines argument
* Revert the default mode to text (as in Python 2.7), and have a binary=True argument instead
Date User Action Args
2017-10-11 10:16:51andrewcleggsetrecipients: + andrewclegg, ncoghlan, steve.dower
2017-10-11 10:16:51andrewcleggsetmessageid: <>
2017-10-11 10:16:51andrewclegglinkissue31756 messages
2017-10-11 10:16:51andrewcleggcreate