Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
This came up inpython/typeshed#12414.
The current implementation offile_digest() does not check the return value offileobj.readinto() forNone:
Lines 232 to 236 in2a5d1eb
| whileTrue: | |
| size=fileobj.readinto(buf) | |
| ifsize==0: | |
| break# EOF | |
| digestobj.update(view[:size]) |
While buffered file objects can't returnNone, unbuffered ones can when they are doing non-blocking I/O. Specifically,file_digest()is documented to takeSocketIO objects, which can very much returnNone:
Lines 694 to 714 in2a5d1eb
| defreadinto(self,b): | |
| """Read up to len(b) bytes into the writable buffer *b* and return | |
| the number of bytes read. If the socket is non-blocking and no bytes | |
| are available, None is returned. | |
| If *b* is non-empty, a 0 return value indicates that the connection | |
| was shutdown at the other end. | |
| """ | |
| self._checkClosed() | |
| self._checkReadable() | |
| ifself._timeout_occurred: | |
| raiseOSError("cannot read from timed out object") | |
| try: | |
| returnself._sock.recv_into(b) | |
| excepttimeout: | |
| self._timeout_occurred=True | |
| raise | |
| excepterrorase: | |
| ife.errnoin_blocking_errnos: | |
| returnNone | |
| raise |
CPython versions tested on:
CPython main branch
Operating systems tested on:
Other