cpython/Modules/_io
6t8k 26800cf25a
gh-95782: Fix io.BufferedReader.tell() etc. being able to return offsets < 0 (GH-99709)
lseek() always returns 0 for character pseudo-devices like
`/dev/urandom` (for other non-regular files, e.g. `/dev/stdin`, it
always returns -1, to which CPython reacts by raising appropriate
exceptions). They are thus technically seekable despite not having seek
semantics.

When calling read() on e.g. an instance of `io.BufferedReader` that
wraps such a file, `BufferedReader` reads ahead, filling its buffer,
creating a discrepancy between the number of bytes read and the internal
`tell()` always returning 0, which previously resulted in e.g.
`BufferedReader.tell()` or `BufferedReader.seek()` being able to return
positions < 0 even though these are supposed to be always >= 0.

Invariably keep the return value non-negative by returning
max(former_return_value, 0) instead, and add some corresponding tests.
2024-02-17 11:16:06 +00:00
..
clinic gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) 2024-02-05 21:49:17 +01:00
_iomodule.c gh-106320: Remove private _PyLong_Sign() (#108743) 2023-09-01 09:13:07 +02:00
_iomodule.h gh-101819: Isolate `_io` (#101948) 2023-05-15 09:26:27 +00:00
bufferedio.c gh-95782: Fix io.BufferedReader.tell() etc. being able to return offsets < 0 (GH-99709) 2024-02-17 11:16:06 +00:00
bytesio.c gh-111049: Fix crash during garbage collection of the BytesIO buffer object (GH-111221) 2023-12-14 10:04:23 +00:00
fileio.c gh-82626: Emit a warning when bool is used as a file descriptor (GH-111275) 2024-02-05 22:51:11 +02:00
iobase.c Fix an incorrect comment in iobase_is_closed (GH-102952) 2024-01-16 18:27:17 +02:00
stringio.c gh-112205: Support `@setter` annotation from AC (gh-112922) 2023-12-13 14:00:34 +00:00
textio.c gh-111140: Adds PyLong_AsNativeBytes and PyLong_FromNative[Unsigned]Bytes functions (GH-114886) 2024-02-12 20:13:13 +00:00
winconsoleio.c gh-77046: os.pipe() sets _O_NOINHERIT flag on fds (#113817) 2024-01-10 23:02:17 +01:00