Title: Using default encoding with `` is not obvious
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: should alias universal_newlines to text
View: 31756
Assigned To: docs@python Nosy List: Xavier Robin, docs@python, eryksun, pekka.klarck
Priority: normal Keywords:

Created on 2018-04-23 08:38 by pekka.klarck, last changed 2020-01-30 01:28 by eryksun. This issue is now closed.

Messages (2)
msg315652 - (view) Author: Pekka Klärck (pekka.klarck) Date: 2018-04-23 08:38
It is possible to use `` 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.
msg361000 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2020-01-30 01:28
This issue was already addressed for 3.x in bpo-31756, which added the a `text` parameter and updated the documentation. As to 2.7, it was officially retired as of the first of this month. Anyway, I don't think there was a pressing need to clarify the documentation in 2.7.
Date User Action Args
2020-01-30 01:28:58eryksunsetstatus: open -> closed

superseder: should alias universal_newlines to text

nosy: + eryksun
messages: + msg361000
resolution: duplicate
stage: needs patch -> resolved
2020-01-29 16:09:46Xavier Robinsetnosy: + Xavier Robin
2018-04-27 18:38:53terry.reedysetnosy: + docs@python
versions: + Python 2.7, Python 3.6, Python 3.7, Python 3.8
assignee: docs@python
components: + Documentation
type: enhancement
stage: needs patch
2018-04-23 08:38:32pekka.klarckcreate