[issue35870] readline() specification is unclear

2019-01-31 Thread Martin Panter


Martin Panter  added the comment:

I agree that the documentation should be clearer about the first two points. 
Considering that the "input" function and by default the "str.splitlines" 
method both behave differently, I often had to re-learn this when I had less 
Python experience.

The expected behaviour as I understand is the line terminator is included if it 
was read. It is not included if the size limit or EOF was reached first. The 
Python 2 documentation 
 is clear about 
both the newline being included and EOF behaviour.

Regarding text files, if you mean the "TextIOWrapper.readline" method, I think 
it is reasonable to assume you get the translated line endings as specified by 
the constructor's "newline" argument: 
. Newline='' and 
newline='\r\n' would keep the '\r\n' terminators, and newline=None would 
translate them to '\n'.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35870] readline() specification is unclear

2019-01-31 Thread Victor Porton


New submission from Victor Porton :

In https://docs.python.org/3/library/io.html it is forgotten to say whether 
'\n' is appened to the return value of readline().

It is also unclear what happens if the last line not terminated by '\n' is read.

It is also unclear what is returned if a text file (say with '\r\n' 
terminators) is read. Is it appended to the return value '\n', '\r\n' or 
nothing?

--
assignee: docs@python
components: Documentation
messages: 334634
nosy: docs@python, porton
priority: normal
severity: normal
status: open
title: readline() specification is unclear
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com