bpo-39259: poplib now rejects timeout = 0 (GH-17912)

poplib.POP3 and poplib.POP3_SSL now raise a ValueError
if the given timeout for their constructor is zero to
prevent the creation of a non-blocking socket.
This commit is contained in:
Dong-hee Na 2020-01-10 23:34:05 +09:00 committed by Victor Stinner
parent 4c53e63cc9
commit c39b52f152
5 changed files with 26 additions and 6 deletions

View file

@ -107,6 +107,8 @@ class POP3:
self.welcome = self._getresp()
def _create_socket(self, timeout):
if timeout is not None and not timeout:
raise ValueError('Non-blocking socket (timeout=0) is not supported')
return socket.create_connection((self.host, self.port), timeout)
def _putline(self, line):