Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-101100: Fix dangling references in test.rst#114958

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
smontanaro wants to merge9 commits intopython:main
base:main
Choose a base branch
Loading
fromsmontanaro:patch-9

Conversation

smontanaro
Copy link
Contributor

@smontanarosmontanaro commentedFeb 3, 2024
edited by github-actionsbot
Loading

Further cleanup related to#114770.

One or two typos. Mostly I just suppressed the dangling references, because this module is just meant for core dev usage.


📚 Documentation preview 📚:https://cpython-previews--114958.org.readthedocs.build/

@@ -1087,12 +1087,12 @@ The :mod:`test.support.socket_helper` module provides support for socket tests.
buildbot environment. This method raises an exception if the
``sock.family`` is :const:`~socket.AF_INET` and ``sock.type`` is
:const:`~socket.SOCK_STREAM`, and the socket has
:const:`~socket.SO_REUSEADDR` or :const:`~socket.SO_REUSEPORT` set on it.
:const:`!SO_REUSEADDR` or :const:`!SO_REUSEPORT` set on it.
Copy link
Member

@AlexWaygoodAlexWaygoodFeb 4, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The better way to fix these two warnings would be to add documentation for these constants in thesocket module docs, if that documentation doesn't already exist. Then we'll also be able to reference these constants in the docs for other modules, as will users of intersphinx outside of CPython

CAM-Gerlach reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Perhaps, but ISTR thesocket module doc explicitly mentions a whole raft of constants as coming from the underlying C socket(2) implementation. That is presumably to keep from duplicating underlying canonical documentation and to avoid introducing mistakes (think platform dependencies).

I understand it would be great to have the Python library docs completely self-contained, but I don't think that's the best way to go in some cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fair point, there are probably too many in the socket module for us to list them all out explicitly!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In that case, we should explicitly list them inconf.py as silenced with a comment explaining why, to avoid introducing noise here, making it easy to change the decision in the future, and ensuring we have a consistent central record of it.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Given that many of the possible constants are only given in thesocket module doc as wildcards (e.g.,SO_*) I don't think that will work unless you only want to list a known (small) subset.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This stuff is really at the fringe between low-level Unix stuff and the relevant Python wrappers. According to Wikipedia, the first edition of Stevens'Unix Network Programming (the network programming bible when I was a wee lad) is 768 pages long. It's not at all clear to me that there's much to be gained by documenting a few socket options. It's not really going to flatten the socket programming learning curve much. Programmers will have to delve into the C socket documentation to do anything serious anyway.

Sorry about the soapbox.

@hugovk
Copy link
Member

🎉

Congratulations! You improved:

Doc/library/test.rst

Please remove from Doc/tools/.nitignore

Let's combine#114770 into this one, they need to be atomic for the CI to be green and mergeable.

@smontanaro
Copy link
ContributorAuthor

Let's combine#114770 into this one

Done. I also closed that PR.

@smontanaro
Copy link
ContributorAuthor

Can we move this forward? Is there more people think needs to be done?

@AlexWaygood
Copy link
Member

Can we move this forward? Is there more people think needs to be done?

there's a merge conflict

@smontanaro
Copy link
ContributorAuthor

there's a merge conflict

Better now? I saw the alert in the web interface, but didn't see a conflict in my sandbox. I must have missed a step in there somewhere. I just resolved it through the web interface.

@smontanaro
Copy link
ContributorAuthor

Once it is merged, let me try to take care of 3.12 and 3.11 (assuming these changes are backported). I have a local version ofcherry_picker with some minimal color support I'd like to exercise a bit.

@CAM-GerlachCAM-Gerlach added needs backport to 3.11only security fixes needs backport to 3.12only security fixes labelsFeb 21, 2024
Copy link
Member

@CAM-GerlachCAM-Gerlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A general comment: IMO, it is much better to just leave valid warnings due to missing documentation than to take the easy way out and just hide them, as doing so defeats one of the most meaningful benefits of these warnings in the first place—identifying gaps in the docs where we haven't formally documented something that should be public. To be honest, I'd rather people not fix the trivial cases at all if that comes at the cost of ignoring the more important ones.

Comment on lines 327 to 328
True if Python was built with the :c:macro:`!Py_DEBUG` macro defined: if
Python is :ref:`built in debug mode <debug-build>`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What's the reason for disabling reference resolution here, sorry? Does it not work, for some reason? Ac:macro: is defined forPy_DEBUG, and the macro definition and surrounding text describes what it means for Python to be built in debug mode, so seems a useful reference here.

Also, this wording change seems a bit incongruous to my eye and the breaks don't either minimize diffs or follow the semantic structure. Therefore, I'd suggest either simplifying the structure and wording with more logical breaks:

Suggested change
True if Python was built with the:c:macro:`!Py_DEBUG` macro defined: if
Python is:ref:`built in debug mode<debug-build>`
True if Python was built with the:c:macro:`Py_DEBUG` macro defined:
i.e. it was:ref:`built in debug mode<debug-build>`

or minimizing diffs to just the essential fixes

Suggested change
True if Python was built with the:c:macro:`!Py_DEBUG` macro defined: if
Python is:ref:`built in debug mode<debug-build>`
True if Python was built with the:c:macro:`Py_DEBUG` macro
defined; that is, if
Python was:ref:`built in debug mode<debug-build>`

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Probably just confusion on my part, though I think in discussing changes totest.rst we might have gone back and forth a bit. Note that the meaning and effects of debug builds are scattered in multiple locations. In my mind defining thePy_DEBUG macro is just the marker for C programmers for what you really care about, creating a debug build. That's discussed in to sections inusing/configure.rst andc-api/intro.rst.

@@ -1087,12 +1087,12 @@ The :mod:`test.support.socket_helper` module provides support for socket tests.
buildbot environment. This method raises an exception if the
``sock.family`` is :const:`~socket.AF_INET` and ``sock.type`` is
:const:`~socket.SOCK_STREAM`, and the socket has
:const:`~socket.SO_REUSEADDR` or :const:`~socket.SO_REUSEPORT` set on it.
:const:`!SO_REUSEADDR` or :const:`!SO_REUSEPORT` set on it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In that case, we should explicitly list them inconf.py as silenced with a comment explaining why, to avoid introducing noise here, making it easy to change the decision in the future, and ensuring we have a consistent central record of it.

@@ -475,7 +475,7 @@ The :mod:`test.support` module defines the following functions:

.. function:: with_pymalloc()

Return :const:`_testcapi.WITH_PYMALLOC`.
Return :const:`!_testcapi.WITH_PYMALLOC`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a constant in an underscored name, test module, so it's not required to document it, but given the entire description of this function is "return ", which doesn't seem terribly useful if said constant is entirely undocumented, it seems worth at least briefly touching on what that actually means here (which the warning is a canary for).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm guessing the reference must be suppressed in some other way, because no hyperlink shows up in the generated HTML (and no warning is emitted by Sphinx). You'll have to take this up with someone above my pay grade.

@@ -969,7 +969,7 @@ The :mod:`test.support` module defines the following functions:

.. function:: skip_if_broken_multiprocessing_synchronize()

Skip tests if the :mod:`multiprocessing.synchronize` module is missing, if
Skip tests if the :mod:`!multiprocessing.synchronize` module is missing, if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is an purposefully undocumented module, I'm guessing?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I couldn't begin to guess why it's undocumented. Maybe it's meant to be semantically identical to the relevantthreading module synchronization primitives?

__all__ = [    'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Condition', 'Event'    ]

I see this comment preceding an import which it suggests might fail:

# Try to import the mp.synchronize module cleanly, if it fails# raise ImportError for platforms lacking a working sem_open implementation.# See issue 3770

There is also a note about this possibility in themultiprocessing module documentation.

Comment on lines 1728 to 1729
The recorder object also has a :meth:`!reset` method, which clears the
warnings list.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a valid, public method ofWarningsRecorder, a class publicly documented just below, that is missing its documentation. Therefore, this warning shouldn't be silenced, as again it indicates a legitimite gap in the docs. The simplest solution seems to move this line to a.. method under theWarningsRecorder class to properly document the method there, instead of overloading the already long and complexcheck_warnings context description with details of the object it returns.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I changed the text to:meth:``~WarningsRecorder.reset`` (how in the heck do I make the raw ReST display correctly in Markdown???) which is fine as far as that goes, but there is no documentation of either the class or the reset method. I'll leave it as-is. There will be a nitpick warning:

.../Doc/library/test.rst:1728: WARNING: py:meth reference target not found: WarningsRecorder.reset

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

(how in the heck do I make the raw ReST display correctly in Markdown???)

Use the fact that GitHub supports HTML tags and escape backquotes:

<code>:meth:\`~WarningsRecorder.reset\`</code>

produces:meth:`~WarningsRecorder.reset`.

@@ -1716,7 +1716,7 @@ The :mod:`test.support.warnings_helper` module provides support for warnings tes

In this case all warnings are caught and no errors are raised.

On entry to the context manager, a :class:`WarningRecorder` instance is
On entry to the context manager, a :class:`WarningsRecorder` instance is
returned. The underlying warnings list from
:func:`~warnings.catch_warnings` is available via the recorder object's
:attr:`warnings` attribute. As a convenience, the attributes of the object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This existing reference resolves but entirely incorrectly; it implieswarnings is an "attribute" of thetest.support.warnings_helper module, and furthermore actually falls back to link to thewarnings stdlib module instead, which is entirely not what is intended. It should presumably be moved to where it belongs, under the class below, instead, to both avoid the misleading reference and properly document it.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is one place where it would be real nice if Sphinx applied some simple semantics to the refs. Something which is an attribute clearly can't be a module. I've qualified the reference. As with thereset reference, it is now broken.

.../Doc/library/test.rst:1719: WARNING: py:attr reference target not found: WarningsRecorder.warnings

Both thereset andwarnings items are fully qualified, so even though the links don't work, the full names are displayed.

@bedevere-app
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be put in the comfy chair!

@smontanaro
Copy link
ContributorAuthor

@CAM-Gerlach I can't see how I'm supposed to respond to your comment about the suppressedSO_REUSEADDR andSO_REUSEPORT attributes. Neither of those attributes is defined in thesocket documentation (though mentioned a couple times). I'm not keen onreproducing bits of external documentation, especially as in this case where it means exactly the same thing in Python as in C.

Also note that the text near these suppressed links says basically, "Don't use these in tests!"

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
@hugovkhugovk removed the needs backport to 3.11only security fixes labelApr 11, 2024
@serhiy-storchakaserhiy-storchaka added the needs backport to 3.13bugs and security fixes labelMay 9, 2024
@hugovkhugovk removed the needs backport to 3.12only security fixes labelApr 10, 2025
@serhiy-storchakaserhiy-storchaka added the needs backport to 3.14bugs and security fixes labelMay 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@picnixzpicnixzpicnixz left review comments

@AlexWaygoodAlexWaygoodAlexWaygood left review comments

@CAM-GerlachCAM-GerlachCAM-Gerlach requested changes

Assignees
No one assigned
Labels
awaiting changesdocsDocumentation in the Doc dirneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixesskip news
Projects
Status: Todo
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@smontanaro@hugovk@AlexWaygood@picnixz@CAM-Gerlach@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp