Skip to content

gh-56915: Fix documented timeout default in ftplib and poplib - #158630

Open
Monstertov wants to merge 1 commit into
python:mainfrom
Monstertov:gh-56915-ftplib-poplib-timeout-docs
Open

Monstertov wants to merge 1 commit into
python:mainfrom
Monstertov:gh-56915-ftplib-poplib-timeout-docs

Conversation

@Monstertov

@Monstertov Monstertov commented Oct 2, 2026 •

Copy link
Copy Markdown

the docs show timeout=None as the default for FTP, FTP.connect, FTP_TLS and POP3_SSL, but none of them actually default to None:

  • FTP, FTP_TLS and POP3_SSL default to socket._GLOBAL_DEFAULT_TIMEOUT, so the global default timeout is used. passing None explicitly disables the timeout, which is the surprise described in the issue.
  • FTP.connect uses a private sentinel and keeps the timeout that was given to the constructor.

this switches those signatures to the [, timeout] form that smtplib, http.client, urllib.request and POP3 already use, fixes the default text for FTP.connect, and corrects the FTP class docstring, which said the timeout defaults to None.

docs and docstring only, no behaviour change, so i think this can skip news.

quick check of the current behaviour:

socket.setdefaulttimeout(7.0)
FTP().connect(host, port)              # sock.gettimeout() -> 7.0
FTP(timeout=None).connect(host, port)  # sock.gettimeout() -> None
FTP(timeout=3).connect(host, port)     # sock.gettimeout() -> 3.0

the docs showed timeout=None for FTP, FTP.connect, FTP_TLS and POP3_SSL,
but the code defaults to the global socket timeout. passing None
disables the timeout instead. use the [, timeout] form like smtplib and
http.client, and say that FTP.connect keeps the constructor timeout.
@Monstertov
Monstertov requested review from a team and giampaolo as code owners October 2, 2026 23:38
@python-cla-bot

python-cla-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Oct 2, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34909323 | 📁 Comparing 419c1a3 against main (1a85213)

  🔍 Preview build  

2 files changed
± library/ftplib.html
± library/poplib.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant