#17572: Avoid chained exceptions while passing bad directives to time.strptime(). Initial patch by Claudiu Popa.

This commit is contained in:
Ezio Melotti 2013-04-04 02:09:20 +03:00
parent a99e1711f7
commit 0f38908684
4 changed files with 16 additions and 1 deletions

View file

@ -326,7 +326,7 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
bad_directive = "%"
del err
raise ValueError("'%s' is a bad directive in format '%s'" %
(bad_directive, format))
(bad_directive, format)) from None
# IndexError only occurs when the format string is "%"
except IndexError:
raise ValueError("stray %% in format '%s'" % format)