Skip to content

馃悰 fix: make 馃獫 intercept parse_intermixed_args() - #351

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:hook-intermixed
Aug 27, 2026
Merged

馃悰 fix: make 馃獫 intercept parse_intermixed_args()#351
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:hook-intermixed

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Aug 27, 2026

Copy link
Copy Markdown
Member

A parser factory that ends in parser.parse_intermixed_args() defeats the :hook: option on Python 3.12 and later. There parse_known_intermixed_args calls _parse_known_args2 instead of parse_known_args, so the monkeypatch does not fire, the real parser reads Sphinx's own argv, and the build dies with error: unrecognized arguments: -b html .... 馃悰

The hook now covers parse_known_intermixed_args as well as parse_known_args, both through the same HookError raise. Both patches live in one patch.object context manager, which also restores the originals when the factory raises something other than HookError; the previous save and restore guarded parse_known_args alone.

Factories that return the parser or call parse_args() behave as before.

@gaborbernat gaborbernat added the bug Something isn't working label Aug 27, 2026
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
gaborbernat merged commit 6bd79f0 into tox-dev:main Aug 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant