You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BufferedIOBase.readinto raises TypeError when called on a non-blocking streams block with no data #162031
From PEP-3116 non-blocking should return None in this case (https://peps.python.org/pep-3116/#non-blocking-i-o). Goal for fixing this now is to normalize what happens between .read and .readinto; TypeError is definitely outside of the documented behavior.
importio, _pyio, osclassReader(io.BufferedIOBase):
defread(self, size=-1):
returnNone# non-blocking, no data availabler, w=os.pipe()
os.set_blocking(r, False)
print(io.open(r, 'rb', closefd=False).readinto(bytearray(1))) # Noneprint(_pyio.open(r, 'rb', closefd=False).readinto(bytearray(1))) # 0Reader().readinto(bytearray(1)) # TypeError: read() should return bytes
This exact fix was proposed in 2015 in nonblock-none.patch on gh-57531, but it never landed as that touched many other broad questsions as well. gh-109523 fixed the same kind of bug in TextIOWrapper: a would-block read should never surface as TypeError.
Activity