SIGN IN SIGN UP

[3.14] gh-140607: Validate returned byte count in RawIOBase.read (GH-140611) (#140728)

* [3.14] gh-140607: Validate returned byte count in RawIOBase.read (GH-140611)

While `RawIOBase.readinto` should return a count of bytes between 0 and
the length of the given buffer, it is not required to. Add validation
inside RawIOBase.read() that the returned byte count is valid.
(cherry picked from commit 0f0a362768aecb4c791724cce486d8317533a94d)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Victor Stinner <vstinner@python.org>

* fixup: Use older attribute name

---------

Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
C
Cody Maloney committed
9a7dccd7a179c82ed50717e7d855e0be558c7c91
Parent: 7c4a8e5
Committed by GitHub <noreply@github.com> on 10/29/2025, 12:31:48 PM