Skip to content

gh-115426: Fix the socket object close() cross-references - #157295

Merged
StanFromIreland merged 1 commit into
python:mainfrom
jang-hs:fix/issue-115426-socket-close-xref
Sep 11, 2026
Merged

gh-115426: Fix the socket object close() cross-references#157295
StanFromIreland merged 1 commit into
python:mainfrom
jang-hs:fix/issue-115426-socket-close-xref

Conversation

@jang-hs

@jang-hs jang-hs commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

The socket object's close() is documented as a method, but the three
cross-references to it resolved to the module-level socket.close(fd)
function instead, so clicking any of them landed on the wrong object.

close is the only name that is both a module-level function (added in 3.7)
and a socket method, and the Python domain matches <module>.<target> before
the class-scoped name, so :meth:socket.close hit the function and won. Every other method reference on the page has no module-level homonym and resolves correctly, which is probably why this went unnoticed. Qualifying the target as `socket.socket.close` matches the neighbouring `:meth:`~socket.socket.ioctl and :meth:~socket.socket.shutdown``.

Two of the three now render as close() rather than socket.close(). That
seemed right rather than incidental, since socket.close() is literally the
name of the fd function and close() is how every other socket method renders
on the page. The bare :meth:close`` references inside close()'s own
description are left alone: Sphinx drops the link on a self-reference, which I
checked is independent of this bug.

@zevisert diagnosed this correctly when filing the issue in 2024. I built the
docs to confirm the link targets before and after, with no change to the
nitpick warning count for socket.rst.

Drafted with AI assistance, reviewed and verified locally before opening.

@python-cla-bot

python-cla-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Sep 11, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Sep 11, 2026
@jang-hs jang-hs changed the title gh-115426: Fix socket object close() cross-references in the socket docs gh-115426: Fix the socket object close() cross-references Sep 11, 2026
The three :meth:`socket.close` references in the socket object section
resolved to the module-level socket.close(fd) function instead of the
socket object's close() method.

close is the only name that is both a module-level function and a socket
method, so the Python domain matched <module>.<target> first; every other
method reference on the page resolves correctly. Qualifying the target as
socket.socket.close, as the neighbouring ioctl and shutdown references
already do, points them at the method.
@jang-hs
jang-hs force-pushed the fix/issue-115426-socket-close-xref branch from d22156b to 0e389ae Compare September 11, 2026 08:09
@StanFromIreland StanFromIreland added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 11, 2026
@StanFromIreland
StanFromIreland merged commit d85fa1a into python:main Sep 11, 2026
39 of 40 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @jang-hs for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Sep 11, 2026
@bedevere-app

bedevere-app Bot commented Sep 11, 2026

Copy link
Copy Markdown

GH-157330 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 11, 2026
@bedevere-app

bedevere-app Bot commented Sep 11, 2026

Copy link
Copy Markdown

GH-157331 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 11, 2026
@bedevere-app

bedevere-app Bot commented Sep 11, 2026

Copy link
Copy Markdown

GH-157332 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants