mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-127260: Improve error consistency in both fromisoformat
implementations (#130134)
In the Python implementation, "Z" was allowed where only "+" or "-" should be allowed in time zone specifiers. In the C implementation, ":" was allowed as a separator between the whole and fractional portion of times (seconds). These have both been forbidden and the error messages harmonized.
This commit is contained in:
parent
46ac85e4d9
commit
427dd10250
4 changed files with 14 additions and 2 deletions
|
@ -3533,6 +3533,8 @@ class TestDateTime(TestDate):
|
|||
'2009-04-32T24:00:00.000000', # Day is invalid before wrapping due to 24:00
|
||||
'2009-13-01T24:00:00.000000', # Month is invalid before wrapping due to 24:00
|
||||
'9999-12-31T24:00:00.000000', # Year is invalid after wrapping due to 24:00
|
||||
'2009-04-19T12:30Z12:00', # Extra time zone info after Z
|
||||
'2009-04-19T12:30:45:334034', # Invalid microsecond separator
|
||||
]
|
||||
|
||||
for bad_str in bad_strs:
|
||||
|
@ -4658,6 +4660,7 @@ class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase):
|
|||
('00:00:00.000', self.theclass(0, 0)),
|
||||
('000000.000000', self.theclass(0, 0)),
|
||||
('00:00:00.000000', self.theclass(0, 0)),
|
||||
('00:00:00,100000', self.theclass(0, 0, 0, 100000)),
|
||||
('1200', self.theclass(12, 0)),
|
||||
('12:00', self.theclass(12, 0)),
|
||||
('120000', self.theclass(12, 0)),
|
||||
|
@ -4725,6 +4728,8 @@ class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase):
|
|||
'12:30:45.123456+12:00:30a', # Extra at end of full time
|
||||
'12.5', # Decimal mark at end of hour
|
||||
'12:30,5', # Decimal mark at end of minute
|
||||
'12:30:45.123456Z12:00', # Extra time zone info after Z
|
||||
'12:30:45:334034', # Invalid microsecond separator
|
||||
]
|
||||
|
||||
for bad_str in bad_strs:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue