]> granicus.if.org Git - python/commitdiff
SF 748201: time.strptime() should display format and date on error
authorRaymond Hettinger <python@rcn.com>
Sun, 13 Jul 2003 01:31:38 +0000 (01:31 +0000)
committerRaymond Hettinger <python@rcn.com>
Sun, 13 Jul 2003 01:31:38 +0000 (01:31 +0000)
Usability fix.  Makes the error message more helpful.

Lib/_strptime.py

index ba9dde09972aff5f31991e7ef7a0e8dee39f3072..635613edcaba6004eb8246b01f0ca3af23cd6c49 100644 (file)
@@ -430,7 +430,8 @@ def strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
         _regex_cache[format] = format_regex
     found = format_regex.match(data_string)
     if not found:
-        raise ValueError("time data did not match format")
+        raise ValueError("time data did not match format:  data=%s  fmt=%s" %
+                         (data_string, format))
     if len(data_string) != found.end():
         raise ValueError("unconverted data remains: %s" %
                           data_string[found.end():])