Skip to content

bpo-12706: timeout sentinel in ftplib and poplib documentation #5309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Doc/library/ftplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Here's a sample session using the :mod:`ftplib` module::

The module defines the following items:

.. class:: FTP(host='', user='', passwd='', acct='', timeout=None, source_address=None)
.. class:: FTP(host='', user='', passwd='', acct='', timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None)

Return a new instance of the :class:`FTP` class. When *host* is given, the
method call ``connect(host)`` is made. When *user* is given, additionally
Expand Down Expand Up @@ -72,7 +72,7 @@ The module defines the following items:
*source_address* parameter was added.


.. class:: FTP_TLS(host='', user='', passwd='', acct='', keyfile=None, certfile=None, context=None, timeout=None, source_address=None)
.. class:: FTP_TLS(host='', user='', passwd='', acct='', keyfile=None, certfile=None, context=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT source_address=None)

A :class:`FTP` subclass which adds TLS support to FTP as described in
:rfc:`4217`.
Expand Down Expand Up @@ -176,7 +176,7 @@ followed by ``lines`` for the text version or ``binary`` for the binary version.
debugging output, logging each line sent and received on the control connection.


.. method:: FTP.connect(host='', port=0, timeout=None, source_address=None)
.. method:: FTP.connect(host='', port=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None)

Connect to the given host and port. The default port number is ``21``, as
specified by the FTP protocol specification. It is rarely needed to specify a
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/poplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The :mod:`poplib` module provides two classes:
be used).


.. class:: POP3_SSL(host, port=POP3_SSL_PORT, keyfile=None, certfile=None, timeout=None, context=None)
.. class:: POP3_SSL(host, port=POP3_SSL_PORT, keyfile=None, certfile=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, context=None)

This is a subclass of :class:`POP3` that connects to the server over an SSL
encrypted socket. If *port* is not specified, 995, the standard POP3-over-SSL
Expand Down
4 changes: 2 additions & 2 deletions Lib/ftplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __exit__(self, *args):
if self.sock is not None:
self.close()

def connect(self, host='', port=0, timeout=-999, source_address=None):
def connect(self, host='', port=0, timeout=_GLOBAL_DEFAULT_TIMEOUT, source_address=None):
'''Connect to host. Arguments are:
- host: hostname to connect to (string, default previous host)
- port: port to connect to (integer, default previous port)
Expand All @@ -144,7 +144,7 @@ def connect(self, host='', port=0, timeout=-999, source_address=None):
self.host = host
if port > 0:
self.port = port
if timeout != -999:
if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
self.timeout = timeout
if source_address is not None:
self.source_address = source_address
Expand Down