Skip to content

Commit 70b8d35

Browse files
committed
Fix jvm_version parsing of non-numeric version suffixes
The old regex captured the entire quoted version string, including non-numeric suffixes like "-internal" or "_312", which broke int() conversion downstream. Now only the leading dot-separated digit groups are captured. These examples now work as expected: * OpenJDK 11.0.9.1-internal -> (11, 0, 9, 1) * OpenJDK 1.8.0_312 -> (1, 8, 0)
1 parent 7a193cc commit 70b8d35

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/scyjava/_jvm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def jvm_version() -> tuple[int, ...]:
135135

136136
def _jvm_version_str_to_tuple(java_version_output: str, java: str) -> tuple[int, ...]:
137137
java_version_output = java_version_output.replace("\n", " ").replace("\r", "")
138-
m = re.match('.* version "([^"]*)"', java_version_output)
138+
m = re.match(r'.*version "(\d+(?:\.\d+)*)', java_version_output)
139139
if not m:
140140
raise RuntimeError(
141141
f"Inscrutable java command output:\n$ {java} -version\n{java_version_output}"

0 commit comments

Comments
 (0)