fix: _is_plain_int on every weekday_set path (from_dict + post-set); shared scan function probes the real guard

This commit is contained in:
Joshua King
2026-09-14 10:53:24 -04:00
parent deb409175a
commit 4163667b07
2 changed files with 112 additions and 134 deletions
+4 -3
View File
@@ -131,7 +131,7 @@ def _validate_weekday_set(weekday_set) -> frozenset[int]:
"weekday_set must not be empty for weekly/custom rules"
)
for entry in weekday_set:
if isinstance(entry, bool) or not isinstance(entry, int):
if not _is_plain_int(entry):
raise RuleValidationError(
f"weekday_set entries must be plain integers, got "
f"{entry!r}"
@@ -367,9 +367,10 @@ class ScheduleRule:
weekday_set = data.get("weekday_set")
if isinstance(weekday_set, (list, tuple)):
# Validate entries as plain ints BEFORE set() coercion, so a
# list like [0, False] cannot collapse False into 0.
# list like [0, False] cannot collapse False into 0 and an
# unhashable/int-subclass entry cannot leak a raw TypeError.
for entry in weekday_set:
if isinstance(entry, bool) or not isinstance(entry, int):
if not _is_plain_int(entry):
raise RuleValidationError(
f"weekday_set entries must be plain integers, got "
f"{entry!r}"