Fix crash and loose matching in adjustver.py version parser#49
Open
jacquelinegarrahan wants to merge 1 commit into
Open
Fix crash and loose matching in adjustver.py version parser#49jacquelinegarrahan wants to merge 1 commit into
jacquelinegarrahan wants to merge 1 commit into
Conversation
The --version regex used unescaped '.' (matching any character) and its re.match() result was used without a None check. A malformed --version value therefore raised an uncaught "TypeError: 'NoneType' object is not subscriptable" traceback instead of a usable error, and inputs like "R7x0x10" were wrongly accepted. Escape the separators, anchor the end of the pattern, and print a clear message + exit(1) when the version cannot be parsed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 crash and loose matching in
adjustver.pyversion parserBranch:
fix/adjustver-version-parsing→masterSummary
.tools/adjustver.pyparses a version string passed via-V/--versionintothe
EPICS_*_VERSIONmacros written toconfigure/CONFIG_*_VERSION. The parserhad two defects:
Unguarded
re.matchresult → uncaught traceback. The result ofre.match(...)was indexed directly (M[2],M[3], …) with noNonecheck. Any version string that failed to match crashed with:
instead of a usable diagnostic.
Unescaped
.in the pattern.r'R?(\d+).(\d+).(\d+)(?:.(\d+))?(-.*)?'used bare
., which matches any character, so malformed inputs such asR7x0x10were silently accepted as if valid.Fix
.tools/adjustver.py:r'R?(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?(-.*)?$'Nonecheck that prints a clear message andsys.exit(1)when theversion cannot be parsed.
Verification
Risk
Low. Behavior is unchanged for every well-formed version string; only
previously-malformed inputs change from "crash / silently mis-parse" to
"explicit error".