Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4a6302b

Browse files
committed
SF 748201: time.strptime() should display format and date on error
Usability fix. Makes the error message more helpful.
1 parent 6272737 commit 4a6302b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/_strptime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ def strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
430430
_regex_cache[format] = format_regex
431431
found = format_regex.match(data_string)
432432
if not found:
433-
raise ValueError("time data did not match format")
433+
raise ValueError("time data did not match format: data=%s fmt=%s" %
434+
(data_string, format))
434435
if len(data_string) != found.end():
435436
raise ValueError("unconverted data remains: %s" %
436437
data_string[found.end():])

0 commit comments

Comments
 (0)