Skip to content

Commit 69e655c

Browse files
committed
Improve error message on : invalid use
1 parent 7548704 commit 69e655c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/_strptime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
462462
z = z[:3] + z[4:]
463463
if len(z) > 5:
464464
if z[5] != ':':
465-
raise ValueError(f"Unconsistent use of :")
465+
msg = f"Unconsistent use of : in {found_dict['z']}"
466+
raise ValueError(msg)
466467
z = z[:5] + z[6:]
467468
hours = int(z[1:3])
468469
minutes = int(z[3:5])

Lib/test/test_strptime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,9 @@ def test_bad_offset(self):
349349
_strptime._strptime("-01:30:30.1234567", "%z")
350350
with self.assertRaises(ValueError):
351351
_strptime._strptime("-01:30:30:123456", "%z")
352-
with self.assertRaises(ValueError):
352+
with self.assertRaises(ValueError) as err:
353353
_strptime._strptime("-01:3030", "%z")
354+
self.assertEqual("Unconsistent use of : in -01:3030", str(err.exception))
354355

355356
def test_timezone(self):
356357
# Test timezone directives.

0 commit comments

Comments
 (0)