Skip to content

Docs: correct API descriptions and identifiers - #161159

Open
methane wants to merge 2 commits into
python:mainfrom
methane:fix-doc4
Open

methane wants to merge 2 commits into
python:mainfrom
methane:fix-doc4

Conversation

@methane

@methane methane commented Nov 2, 2026

Copy link
Copy Markdown
Member
  • c-api/typeobj: Replace the invalid PyType_Type->tp_call expression with Py_TYPE(type)->tp_call.
  • c-api/gcsupport: Correct the source of a reused tp_traverse handler to a base class.
  • c-api/gen: Clarify that generator objects are created by calling generator functions.
  • c-api/object: Correct the subclass check explanation: cls appears in derived.__mro__.
  • c-api/frame: Remove the incorrect claim that PyFrame_GetLasti() handles f_lasti being None.
  • howto/descriptor: Correct the simulated slots storage attribute name to _slotvalues.
  • howto/enum: Replace the invalid %h formatting example with %x for IntEnum.
  • howto/isolating-extensions: Describe PyCMethod’s kwnames argument as a tuple of keyword argument names.
  • howto/perf_profiling: Correct the JIT dump filename to /tmp/jit-$PID.dump.
  • howto/remote_debugging: Correct the executable path attribute name to sys._base_executable.
  • library/bz2: Clarify that BZ2Decompressor.needs_input refers to new compressed input.
  • library/dis: Correct LOAD_SUPER_ATTR’s name index calculation to use a right shift.
  • library/textwrap: Describe lowercase letters using string.ascii_lowercase, matching the algorithm’s [a-z] range.
  • reference/expressions: Correct the asynchronous generator finalization example to reference asyncio.BaseEventLoop.shutdown_asyncgens.

@methane methane added docs Documentation in the Doc dir skip issue skip news needs backport to 3.14 bugs and security fixes labels Nov 2, 2026
@methane methane added the needs backport to 3.15 bugs and security fixes label Nov 2, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Nov 2, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The documentation incorrectly identifies shutdown_asyncgens() as the async-generator finalizer callback instead of BaseEventLoop._asyncgen_finalizer_hook, which accepts a generator and schedules its aclose().

1 open issue
What changed in this PR

This documentation-only PR corrects API descriptions, identifiers, and examples across CPython’s C API reference, HOWTOs, library documentation, and language reference.

Changes:

  • Correct C API behavior descriptions and type-slot references.
  • Fix HOWTO identifiers, formatting examples, and profiling paths.
  • Clarify library behavior and update the asynchronous generator finalization reference.
File Description
Doc/​reference/​expressions.rst Updates the asynchronous generator finalization reference.
Doc/​library/​textwrap.rst Clarifies the lowercase characters used for sentence detection.
Doc/​library/​dis.rst Corrects the LOAD_SUPER_ATTR index shift direction.
Doc/​library/​bz2.rst Clarifies that decompression requires compressed input.
Doc/​howto/​remote_debugging.rst Corrects the executable-path attribute name.
Doc/​howto/​perf_profiling.rst Corrects the JIT dump filename.
Doc/​howto/​isolating-extensions.rst Corrects the comment describing kwnames.
Doc/​howto/​enum.rst Replaces an invalid integer formatting example.
Doc/​howto/​descriptor.rst Corrects the simulated slots storage attribute name.
Doc/​c-api/​typeobj.rst Corrects the metaclass call-slot expression.
Doc/​c-api/​object.rst Corrects the subclass relationship explanation.
Doc/​c-api/​gen.rst Clarifies how generator objects are created.
Doc/​c-api/​gcsupport.rst Corrects the source of a reused traversal handler.
Doc/​c-api/​frame.rst Removes an incorrect PyFrame_GetLasti() return-value claim.

Review effort: Balanced

Comment thread Doc/reference/expressions.rst Outdated
registered *finalizer* to be called upon finalization. For a reference example
of a *finalizer* method see the implementation of
``asyncio.Loop.shutdown_asyncgens`` in :source:`Lib/asyncio/base_events.py`.
``asyncio.BaseEventLoop.shutdown_asyncgens`` in
generator-iterator will store the registered *finalizer* to be called upon
finalization. For a reference example of a *finalizer* method see the
implementation of ``asyncio.BaseEventLoop._asyncgen_finalizer_hook`` in
:source:`Lib/asyncio/base_events.py`.

@methane methane Nov 2, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@1st1 @asvetlov would you review this part of change?

The documentation conflates async generator finalization during garbage collection with event loop shutdown. The finalizer registered with sys.set_asyncgen_hooks() is called when a generator is about to be garbage collected, while loop.shutdown_asyncgens() explicitly closes the generators tracked by the loop. This change clarifies that distinction and references _asyncgen_finalizer_hook() as the correct callback example.

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

Labels

awaiting core review docs Documentation in the Doc dir needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes skip issue skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants