馃悰 fix(docstring): survive a re-entrant docstring handler - #758
Merged
gaborbernat merged 1 commit intoAug 24, 2026
Merged
Conversation
process_docstring published three values on the config for the formatting code to read, then deleted them on the way out. Documenting one object can begin documenting another before the first finishes, through a typehints_formatter that renders a nested object or, before tox-dev#624, through an autodoc directive inside a docstring the rtype probe parsed. The inner call deleted the attributes, the outer call then failed its own teardown, and Sphinx aborted the build with "'Config' object has no attribute '_annotation_globals'". The teardown now restores whatever it found instead of deleting, so the outer call gets its own state back and the innermost one clears it. Closes tox-dev#750
gaborbernat
force-pushed
the
fix-750-reentrant-config-state
branch
from
August 24, 2026 14:37
90d8635 to
1e8e1ac
Compare
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.
Building the docs died with
ExtensionError: Handler <function process_docstring ...> threw an exception (exception: 'Config' object has no attribute '_annotation_globals'), reported in #750 against 3.5-3.6.process_docstringhangs three values off the config for the formatting code to read and deletes them in afinally. That works until documenting one object starts documenting another before the first one finishes: the inner call deletes the attributes, and the outer call then raises on its own teardown, which is the error the reporter saw. On their version an autodoc directive sitting in a docstring was enough, because the throwaway parse that places:rtype:ran it. The reproducer below builds clean since #624 neutralized those directives.A
typehints_formatterthat documents a nested object still re-enters the handler onmain, and still aborts the build the same way. Rather than block re-entry, the teardown now puts back whatever it found: an inner call restores the outer call's values, and the outermost call clears them. Nesting turns into an ordinary save and restore, whatever the caller did to reach it. 馃攣