Fix sphinx-doc__sphinx-9711#14387
Closed
piyushhhxyz wants to merge 1 commit intosphinx-doc:masterfrom
Closed
Conversation
The needs_extensions check was comparing version strings lexicographically, which incorrectly rejects versions like 0.10.0 when 0.6.0 is required (since '0.6' > '0.10' as strings). Now uses packaging.version.parse for proper semantic version comparison.
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.
Fix: needs_extensions checks versions using strings
Problem
The
needs_extensionscheck insphinx/extension.pycompared version strings lexicographically (reqversion > extension.version). This causes incorrect rejections when version numbers have components >= 10, e.g.,'0.6' > '0.10'isTrueas a string comparison, but0.6 < 0.10semantically.Fix
Changed the version comparison on line 54 of
sphinx/extension.pyto usepackaging.version.parse()for proper semantic version comparison instead of raw string comparison.Changes
sphinx/extension.py: Importpackaging.version.parseand use it to comparereqversionandextension.versioninverify_needs_extensions().Testing
Verified that
parse_version('0.6') > parse_version('0.10')correctly returnsFalse(whereas string comparison'0.6' > '0.10'incorrectly returnsTrue).