Skip to content

Commit 5580d17

Browse files
donBarbospganssle
andauthored
Apply suggestions from code review
Co-authored-by: Paul Ganssle <[email protected]>
1 parent b0a1707 commit 5580d17

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Lib/_pydatetime.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,8 @@ def _parse_isoformat_time(tstr):
502502
tzsign = -1 if tstr[tz_pos - 1] == '-' else 1
503503

504504
try:
505+
# This function is intended to validate datetimes, but because
506+
# we restrict time zones to ±24h, it serves here as well.
505507
_check_time_fields(hour=tz_comps[0], minute=tz_comps[1],
506508
second=tz_comps[2], microsecond=tz_comps[3],
507509
fold=0)
@@ -1647,7 +1649,7 @@ def fromisoformat(cls, time_string):
16471649
raise error_from_tz
16481650
if error_from_components:
16491651
raise ValueError(
1650-
"minute, second, and microsecond must be 0 when hour is 24"
1652+
"Minute, second, and microsecond must be 0 when hour is 24"
16511653
)
16521654

16531655
return cls(*time_components)

Lib/test/datetimetester.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,6 +3569,8 @@ def test_fromisoformat_fails_datetime(self):
35693569
'2009-04-19T12:30:45. 400', # Space before fraction (gh-130959)
35703570
'2009-04-19T12:30:45+00:90:00', # Time zone field out from range
35713571
'2009-04-19T12:30:45+00:00:90', # Time zone field out from range
3572+
'2009-04-19T12:30:45-00:90:00', # Time zone field out from range
3573+
'2009-04-19T12:30:45-00:00:90', # Time zone field out from range
35723574
]
35733575

35743576
for bad_str in bad_strs:

Modules/_datetimemodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ parse_isoformat_time(const char *dtstr, size_t dtlen, int *hour, int *minute,
11351135
rv = parse_hh_mm_ss_ff(tzinfo_pos, p_end, &tzhour, &tzminute, &tzsecond,
11361136
tzmicrosecond);
11371137

1138-
// Check if Timezone fields are in range
1138+
// Check if timezone fields are in range
11391139
if (check_time_args(tzhour, tzminute, tzsecond, *tzmicrosecond, 0) < 0) {
11401140
return -6;
11411141
}

0 commit comments

Comments
 (0)