Skip to content

Commit 5157850

Browse files
sourcehawkclaude
andcommitted
fix(skills/bounding-heavy-commands): limit each --measure-rows value to six digits
The last fix relied on int() refusing a number with too many digits, but Python 3.9 has no such limit, so the new test failed there. Each value now has at most six digits, which the parser checks itself on every version, and the option error names the range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d43b00d commit 5157850

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

‎skills/bounding-heavy-commands/scripts/bounded_run.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -993,13 +993,10 @@ def parse_arguments(argv: Sequence[str]) -> Options:
993993
options.label = value
994994
elif flag == "--measure-rows":
995995
parts = value.split(",")
996-
try:
997-
rows = [int(part) for part in parts if re.fullmatch(r"[0-9]+", part)]
998-
except ValueError:
999-
# int() refuses a number with more digits than its limit.
1000-
rows = []
996+
# int() of a very long number is slow on some versions of Python and raises ValueError on others.
997+
rows = [int(part) for part in parts if re.fullmatch(r"[0-9]{1,6}", part)]
1001998
if len(rows) != len(parts) or min(rows) < 1:
1002-
raise WrapperError("cannot read --measure-rows '%s'; use whole numbers of 1 or more, such as 16,8,4" % value)
999+
raise WrapperError("cannot read --measure-rows '%s'; use whole numbers from 1 to 999999, such as 16,8,4" % value)
10031000
options.rows = sorted(set(rows), reverse=True)
10041001
options.measure = True
10051002
else:

‎skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,7 @@ def test_rejects_bad_rows_and_labels(self):
12691269
["--measure-rows", "4,,2", "--", "tool"],
12701270
["--measure-rows", "\u00b2", "--", "tool"],
12711271
["--measure-rows", "9" * 5000, "--", "tool"],
1272+
["--measure-rows", "1000000", "--", "tool"],
12721273
["--measure-rows", "4,2", "--cpus", "2", "--", "tool"],
12731274
["--measure", "--label", "unit tests", "--", "tool"],
12741275
["--measure", "--label", "-", "--", "tool"],

0 commit comments

Comments
 (0)