gh-115426: Fix the socket object close() cross-references - #157295
Merged
StanFromIreland merged 1 commit intoSep 11, 2026
Conversation
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
force-pushed
the
fix/issue-115426-socket-close-xref
branch
from
September 11, 2026 08:09
d22156b to
0e389ae
Compare
StanFromIreland
approved these changes
Sep 11, 2026
|
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. |
|
GH-157330 is a backport of this pull request to the 3.15 branch. |
|
GH-157331 is a backport of this pull request to the 3.14 branch. |
|
GH-157332 is a backport of this pull request to the 3.13 branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The socket object's
close()is documented as a method, but the threecross-references to it resolved to the module-level
socket.close(fd)function instead, so clicking any of them landed on the wrong object.
closeis 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>beforethe class-scoped name, so
:meth:socket.closehit 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.ioctland:meth:~socket.socket.shutdown``.Two of the three now render as
close()rather thansocket.close(). Thatseemed right rather than incidental, since
socket.close()is literally thename of the fd function and
close()is how every other socket method renderson the page. The bare
:meth:close`` references insideclose()'s owndescription 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.
.closemethods to module levelsocket.close(fd)#115426