Skip to content

fix: handle '+' suffix in Bugzilla version strings#2

Open
AmSach wants to merge 1 commit into
mainfrom
fix/version-splitting-plus-suffix
Open

fix: handle '+' suffix in Bugzilla version strings#2
AmSach wants to merge 1 commit into
mainfrom
fix/version-splitting-plus-suffix

Conversation

@AmSach
Copy link
Copy Markdown
Owner

@AmSach AmSach commented May 15, 2026

Fixed the bug described in issue python-bugzilla#238.

What was wrong

Version strings like "5.2+" caused a ValueError when parsing because the code called int("2+") which fails. The traceback was printed even though the fallback to version 5.0 worked.

How I fixed it

Changed _set_bz_version to strip non-digit characters from each version part before conversion using filter(str.isdigit, ...). Now "5.2+" correctly becomes (5, 2) without any traceback.

Before:
major, minor = [int(i) for i in version.split(".")[0:2]] # int("2+") -> ValueError

After:
parts = version.split(".")[0:2]
major = int("".join(filter(str.isdigit, parts[0]))) # "5" -> 5
minor = int("".join(filter(str.isdigit, parts[1]))) if len(parts) > 1 else 0 # "2+" -> 2

Tested by

  • Syntax check passed
  • Import check passed
  • Manually verified the logic handles "5.2+", "5.2.1+", "5.2", and malformed strings correctly

Fixes python-bugzilla#238

Version strings like '5.2+' caused a ValueError when parsing because
int() was called on '2+' instead of '2'. This change strips non-digit
characters from each version part before conversion, so '5.2+' becomes
(5, 2) instead of crashing with a traceback.

Fixes python-bugzilla#238
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incomplete / incorrect version splitting for REST API endpoint

1 participant