Skip to content

Commit e780e2c

Browse files
committed
Tighten the _read() comment
1 parent 87bb302 commit e780e2c

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

Lib/_pydatetime.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,7 @@ def _parse_isoformat_date(dtstr):
361361
if len(dtstr) not in (7, 8, 10):
362362
raise ValueError("Invalid isoformat string")
363363
def _read(s, n):
364-
# Each date field is a fixed width of exactly n ASCII digits. int()
365-
# would otherwise accept a leading sign or whitespace, or a short slice
366-
# that runs off the end of the string, so validate before converting
367-
# (this is what the C accelerator's parse_digits() enforces).
364+
# Require exactly n ASCII digits, as the C parse_digits() does.
368365
if len(s) != n or not all(map(_is_ascii_digit, s)):
369366
raise ValueError(f"Invalid isoformat string: {dtstr!r}")
370367
return int(s)

0 commit comments

Comments
 (0)