classification
Title: TextIOWrapper(newline="\n", line_buffering=True) mistakenly treat \r as a newline
Type: behavior Stage: resolved
Components: Documentation, IO Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Elena.Oat, Mariatta, akira, benjamin.peterson, docs@python, hynek, miss-islington, serhiy.storchaka, stutzbach
Priority: normal Keywords: easy, patch

Created on 2014-07-25 16:43 by akira, last changed 2018-05-14 16:25 by Mariatta. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6609 merged Elena.Oat, 2018-04-26 10:25
PR 6801 merged miss-islington, 2018-05-14 14:49
PR 6802 merged miss-islington, 2018-05-14 14:50
PR 6803 merged miss-islington, 2018-05-14 14:51
Messages (8)
msg223965 - (view) Author: Akira Li (akira) * Date: 2014-07-25 16:43
TextIOWrapper(b, newline="\n", line_buffering=True) object calls flush() 
while writing "\r". See test_line_buffering() method in 
Lib/test/test_io.py:2114

The documentation says [1]:

> If line_buffering is True, flush() is implied when a call to write contains
> a newline character.

i.e., writing \r shouldn't force flush() if newline="\n"

[1] https://docs.python.org/3.4/library/io.html#io.TextIOWrapper
msg224078 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-07-26 17:11
Looks as this behavior is intentional. Documentation should be corrected.
msg315785 - (view) Author: Elena Oat (Elena.Oat) * Date: 2018-04-26 10:12
Note that the correct link to the test case is:
https://github.com/python/cpython/blob/master/Lib/test/test_io.py#L2565
msg316513 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2018-05-14 14:48
New changeset 7ffd4c58fae08b29259eebd6cbcd2287820b14e8 by Mariatta (Elena Oat) in branch 'master':
bpo-22069: Update TextIO documentation (GH-6609)
https://github.com/python/cpython/commit/7ffd4c58fae08b29259eebd6cbcd2287820b14e8
msg316528 - (view) Author: miss-islington (miss-islington) Date: 2018-05-14 16:08
New changeset 050e041bf7e5260013a74c75a05a3f0fb16447ec by Miss Islington (bot) in branch '3.7':
bpo-22069: Update TextIO documentation (GH-6609)
https://github.com/python/cpython/commit/050e041bf7e5260013a74c75a05a3f0fb16447ec
msg316529 - (view) Author: miss-islington (miss-islington) Date: 2018-05-14 16:11
New changeset 84fc6c59cf286fc4e6b3a700c6db36ecc2bff92b by Miss Islington (bot) in branch '2.7':
bpo-22069: Update TextIO documentation (GH-6609)
https://github.com/python/cpython/commit/84fc6c59cf286fc4e6b3a700c6db36ecc2bff92b
msg316530 - (view) Author: miss-islington (miss-islington) Date: 2018-05-14 16:18
New changeset 9fd5b5fdf851d35a5c1314360119850e86a1fd0d by Miss Islington (bot) in branch '3.6':
bpo-22069: Update TextIO documentation (GH-6609)
https://github.com/python/cpython/commit/9fd5b5fdf851d35a5c1314360119850e86a1fd0d
msg316534 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2018-05-14 16:25
Thanks!
History
Date User Action Args
2018-05-14 16:25:15Mariattasetresolution: fixed
2018-05-14 16:25:06Mariattasetstatus: open -> closed

stage: patch review -> resolved
messages: + msg316534
versions: + Python 2.7, Python 3.6
2018-05-14 16:18:27pitrousetnosy: - pitrou
2018-05-14 16:18:09miss-islingtonsetmessages: + msg316530
2018-05-14 16:11:44miss-islingtonsetmessages: + msg316529
2018-05-14 16:08:59miss-islingtonsetnosy: + miss-islington
messages: + msg316528
2018-05-14 14:51:13miss-islingtonsetpull_requests: + pull_request6487
2018-05-14 14:50:16miss-islingtonsetpull_requests: + pull_request6486
2018-05-14 14:49:14miss-islingtonsetpull_requests: + pull_request6485
2018-05-14 14:48:03Mariattasetnosy: + Mariatta
messages: + msg316513
2018-04-26 10:25:07Elena.Oatsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request6305
2018-04-26 10:12:59Elena.Oatsetnosy: + Elena.Oat
messages: + msg315785
2018-04-25 17:22:17cheryl.sabellasetkeywords: + easy
stage: needs patch
versions: + Python 3.7, Python 3.8, - Python 2.7, Python 3.4, Python 3.5
2014-07-26 17:11:57serhiy.storchakasetnosy: + hynek, stutzbach, benjamin.peterson, pitrou, docs@python
messages: + msg224078

assignee: docs@python
components: + Documentation
2014-07-26 17:00:59serhiy.storchakasetnosy: + serhiy.storchaka
2014-07-25 16:43:43akiracreate