馃悰 fix: make 馃獫 intercept parse_intermixed_args() - #351
Merged
Conversation
gaborbernat
force-pushed
the
hook-intermixed
branch
from
August 27, 2026 16:09
948525b to
92e4542
Compare
Since Python 3.12 parse_known_intermixed_args calls _parse_known_args2 directly, so a factory ending in parse_intermixed_args() skipped the :hook: monkeypatch, parsed Sphinx's argv and exited the build. Patch parse_known_intermixed_args alongside parse_known_args, through one patch.object context manager that restores both on any exception.
gaborbernat
force-pushed
the
hook-intermixed
branch
from
August 27, 2026 16:12
92e4542 to
9176e1f
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.
A parser factory that ends in
parser.parse_intermixed_args()defeats the:hook:option on Python 3.12 and later. Thereparse_known_intermixed_argscalls_parse_known_args2instead ofparse_known_args, so the monkeypatch does not fire, the real parser reads Sphinx's own argv, and the build dies witherror: unrecognized arguments: -b html .... 馃悰The hook now covers
parse_known_intermixed_argsas well asparse_known_args, both through the sameHookErrorraise. Both patches live in onepatch.objectcontext manager, which also restores the originals when the factory raises something other thanHookError; the previous save and restore guardedparse_known_argsalone.Factories that return the parser or call
parse_args()behave as before.