bpo-39259: nntplib.NNTP/NNTP_SSL now reject timeout = 0 (GH-17936)

nntplib.NNTP and nntplib.NNTP_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-12 02:39:15 +09:00 committed by Victor Stinner
parent 136735c1a2
commit 1b335ae281
5 changed files with 24 additions and 0 deletions

View file

@ -1056,6 +1056,8 @@ class NNTP(_NNTPBase):
raise
def _create_socket(self, timeout):
if timeout is not None and not timeout:
raise ValueError('Non-blocking socket (timeout=0) is not supported')
sys.audit("nntplib.connect", self, self.host, self.port)
return socket.create_connection((self.host, self.port), timeout)