Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/python/base_cli/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def display_command(cli_name: str, argv: list[str]) -> str:


def parse_positive_int(option: str, value: str) -> int:
if not value.isdigit():
if not value.isdecimal():
raise ValueError(f"Option '{option}' must be a positive integer.")
amount = int(value)
if amount <= 0:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ def test_msvcrt_backend_uses_a_private_sidecar_lock(self) -> None:

self.assertEqual(fake_msvcrt.calls, [(_FakeMsvcrt.LK_LOCK, 1), (_FakeMsvcrt.LK_UNLCK, 1)])


class PositiveIntegerTests(unittest.TestCase):
def test_parse_positive_int_rejects_digit_like_non_decimal_characters(self) -> None:
with self.assertRaisesRegex(ValueError, "Option '--limit' must be a positive integer"):
history.parse_positive_int("--limit", "²")

def test_parse_positive_int_accepts_decimal_digits(self) -> None:
self.assertEqual(history.parse_positive_int("--limit", "١٢"), 12)

def test_msvcrt_sidecar_initialization_race_is_tolerated(self) -> None:
fake_msvcrt = _FakeMsvcrt()
original_write = history.os.write
Expand Down