Skip to content

parse_positive_int accepts Unicode digit characters that then crash int() with a raw, unfriendly exception #145

Description

@codeforester

Summary

parse_positive_int's input guard uses str.isdigit(), which is True for non-ASCII digit-like characters that int() can't actually parse.

Details

lib/python/base_cli/history.py:261-267. Verified: '²'.isdigit() (superscript two) is True, but int('²') raises ValueError: invalid literal for int() with base 10: '²'. The whole purpose of this public helper (exported in history.__all__) is to turn bad input into a friendly ValueError(f"Option '{option}' must be a positive integer.").

Impact

This specific class of input instead raises an unhandled internal ValueError with a confusing raw message — the opposite of what the function promises. Any consumer using it for flags like --limit N inherits the same gap.

Suggested fix

Use value.isdecimal() (or a regex ^[0-9]+$) instead of isdigit().

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Status
Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions