Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
escape the dot in the regex, avoiding cases of garbage between two nu…
Browse files Browse the repository at this point in the history
…mbers
  • Loading branch information
lev-blit authored and asottile committed Dec 21, 2022
1 parent 8f8f229 commit 73a8e1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import re

PATTERN = re.compile(r'^(\d+).(\d+)$', re.ASCII)
PATTERN = re.compile(r'^(\d+)\.(\d+)$', re.ASCII)


def manylinux_compatible(major: int, minor: int, arch: str) -> bool:
Expand Down
9 changes: 9 additions & 0 deletions tests/manylinux_max_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ def test_environment_variable_is_garbage():

msg, = excinfo.value.args
assert msg == 'invalid MANYLINUX_MAX, expected `#.##` got `garbage`'


def test_environment_variable_non_dot():
with mock.patch.dict(os.environ, {'MANYLINUX_MAX': '2_28'}):
with pytest.raises(ValueError) as excinfo:
manylinux_compatible(2, 28, 'x86_64')

msg, = excinfo.value.args
assert msg == 'invalid MANYLINUX_MAX, expected `#.##` got `2_28`'

0 comments on commit 73a8e1e

Please sign in to comment.