Skip to content

Reword atexit docs - #156086

Open
encukou wants to merge 1 commit into
python:mainfrom
encukou:atexit-interpreter
Open

Reword atexit docs#156086
encukou wants to merge 1 commit into
python:mainfrom
encukou:atexit-interpreter

Conversation

@encukou

@encukou encukou commented Aug 20, 2026

Copy link
Copy Markdown
Member

For the atexit module:

  • Move common info from register to the module level (a lot of this was duplicated -- less maintainable and harder to read)
  • Use interpreter shutdown consistently, introducing it as a more general term for the old docs' "program termination".
  • Use consistent terminology (exit handlers)
  • Move warning for a mitigated footgun to a change entry
  • Add a new warning about keeping things usable

Similarly clarify docs for the atexit attribute in weakref.

For the `atexit` module:

- Move common info from `register` to the module level (a  lot of this
  was duplicated -- less maintainable and harder to read)
- Use *interpreter shutdown* consistently, introducing it as a more
  general term for the old docs' "program termination".
- Use consistent terminology (exit handlers)
- Move warning for a mitigated footgun to a change entry
- Add a new warning about keeping things usable

Similarly clarify docs for the `atexit` attribute in `weakref`.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34150483 | 📁 Comparing 1354c91 against main (5be8020)

  🔍 Preview build  

2 files changed
± library/atexit.html
± library/weakref.html

Comment thread Doc/library/atexit.rst
Comment on lines 38 to 39
**Note:** The effect of registering or unregistering functions from within
a cleanup function is undefined.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is defined starting in 3.15; Python will run any handlers that have been added.

Comment thread Doc/library/atexit.rst
Attempts to start a new thread or :func:`os.fork` a new process
in an exit handler now leads to :exc:`RuntimeError`.
Previously, this could cause race conditions between the main Python
runtime thread freeing thread states while internal :mod:`threading`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Link to the term here?

Suggested change
runtime thread freeing thread states while internal :mod:`threading`
runtime thread freeing :term:`thread states <thread state>` while internal :mod:`threading`

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

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants