New submission from Martin Larralde <martin.larra...@embl.de>:

The documentation for `IOBase.readlines` states that the `hint` optional 
argument should be used like so 
(https://docs.python.org/3/library/io.html#io.IOBase.readlines):

> 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

io.BytesIO(b"abc\ndef\nghi\n").readlines(0) 
# 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.

----------
assignee: docs@python
components: Documentation
messages: 386484
nosy: althonos2, docs@python
priority: normal
severity: normal
status: open
title: IOBase.readlines(0) behaviour is inconsistent with documentation
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43126>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to