Fix sphinx-doc__sphinx-9711: needs_extensions checks versions using strings#14384
Closed
piyushhhxyz wants to merge 1 commit intosphinx-doc:masterfrom
Closed
Fix sphinx-doc__sphinx-9711: needs_extensions checks versions using strings#14384piyushhhxyz wants to merge 1 commit intosphinx-doc:masterfrom
piyushhhxyz wants to merge 1 commit intosphinx-doc:masterfrom
Conversation
The needs_extensions check was comparing version strings using plain string comparison, which incorrectly treats '0.6' > '0.10' because '6' > '1' in lexicographic order. This caused extensions with versions >= 0.10 to be rejected when the minimum required version was lower (e.g., 0.6). Fix by using packaging.version.parse() for proper semantic version comparison. Fixes sphinx-doc#9711
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.
Summary
Fix
needs_extensionsversion comparison to use proper semantic versioning instead of string comparison.Problem
The
verify_needs_extensionsfunction insphinx/extension.pycompared version strings using plain Python string comparison (reqversion > extension.version). This causes incorrect results for multi-digit version components because string comparison is lexicographic:'0.6' > '0.10'evaluates toTrue(because'6' > '1')0.10is newer than0.6This meant extensions at version 0.10+ would be incorrectly rejected when the minimum required version was lower (e.g., 0.6).
Fix
Replace the string comparison with
packaging.version.parse()for proper semantic version comparison:packagingis already a dependency of Sphinx and is used elsewhere in the codebase (e.g.,sphinx/ext/doctest.py).Fixes #9711