Title: IOBase.readlines(0) behaviour is inconsistent with documentation
Type: behavior Stage:
Components: Documentation Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: althonos2, docs@python
Priority: normal Keywords:

Created on 2021-02-04 14:28 by althonos2, last changed 2021-02-04 14:28 by althonos2.

Messages (1)
msg386484 - (view) Author: Martin Larralde (althonos2) Date: 2021-02-04 14:28
The documentation for `IOBase.readlines` states that the `hint` optional argument should be used like so (

> Read and return a list of lines from the stream. hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.

So in the case where `hint` is null, I would expect `readlines` to return an empty list.

However, this is neither the case for `io.BytesIO` nor for `io.FileIO`:

import io

# this evaluates to [b"abc\n", b"def\n", b"ghi\n"]

If this is the intended behaviour, the documentation should be updated, otherwise the code from the `io` module should be fixed.
Date User Action Args
2021-02-04 14:28:07althonos2create