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.

classification
Title: Hard-coded line ending in asyncio.streams.StreamReader.readline
Type: behavior Stage: resolved
Components: asyncio Versions: Python 3.6, Python 3.4, Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, barry, eric.smith, gvanrossum, jaraco, martin.panter, r.david.murray, vstinner, yselivanov
Priority: normal Keywords:

Created on 2015-09-27 22:34 by eric.smith, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg251732 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2015-09-27 22:34
A group of us (all added as nosy) spent part of the day working on issue 25008 (write an smtpd with asyncio).

We came across some code that contained a copy of StreamReader.readline, but it used b'\r\n' instead of b'\n' for a line ending character. In StreamReader.readline, '\n' is hard coded.

I'd like to propose that the line ending be passed in to readline, with a default of b'\n', and that multi-byte line ending sequences be explicitly supported.

Further, I'm hoping we can treat this as a bug and not a feature request, so that it can go in to 3.4 and 3.5. Adding a default parameter will be backward compatible.
msg251733 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2015-09-27 23:34
Hm... Since \r\n ends with \n, what exactly would it help to pass in \r\n as the desired line ending? In either case the entire line (including the \r\n) would be returned.

Unless you have a need for treating foo\nbar\r\n as a single line? (But why would you?)  I'm guessing I'm missing something?

No worries about the bug/feature distinction, for asyncio we can do whatever we want (it's still provisional in 3.5).
msg251738 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2015-09-28 00:59
Good point. I quick test of our sample code shows that calling regular readline to read up to '\n' does in fact work correctly. Let me do some more testing, then I'll likely close this.

Thanks!
msg251797 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2015-09-28 20:13
I'm closing this as unneeded.
msg255527 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-11-28 04:46
Eric seems to have retracted this proposal, however Issue 25752 has also been opened, which sounds very similar.
History
Date User Action Args
2022-04-11 14:58:21adminsetgithub: 69439
2015-11-28 04:46:40martin.pantersetstatus: open -> closed
nosy: + martin.panter
messages: + msg255527

2015-09-28 20:13:52eric.smithsetresolution: rejected
messages: + msg251797
stage: resolved
2015-09-28 00:59:36eric.smithsetmessages: + msg251738
2015-09-27 23:34:00gvanrossumsetmessages: + msg251733
2015-09-27 22:34:35eric.smithcreate