summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-11-24 16:17:11 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-11-24 16:17:11 (GMT)
commitb5d386314fc9f66f9f69399da9b32bf0b6504033 (patch)
tree7dba719b73fe92f52645bbee8da63652f9f207e6 /Lib/test
parent4d01c4b6bbb7b35edd8cd4f4577e2c97cba8b9fa (diff)
parentcdac302af362f275f31c13e143f78ec682ef7b68 (diff)
downloadcpython-b5d386314fc9f66f9f69399da9b32bf0b6504033.zip
cpython-b5d386314fc9f66f9f69399da9b32bf0b6504033.tar.gz
cpython-b5d386314fc9f66f9f69399da9b32bf0b6504033.tar.bz2
Issue #19545: Avoid chained exceptions while passing stray % to
time.strptime(). Initial patch by Claudiu Popa.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_strptime.py4
-rw-r--r--Lib/test/test_time.py4
2 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 68e6a67..d5bc39d 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -223,6 +223,10 @@ class StrptimeTests(unittest.TestCase):
with self.assertRaises(ValueError) as e:
_strptime._strptime_time('', '%D')
self.assertIs(e.exception.__suppress_context__, True)
+ # additional check for IndexError branch (issue #19545)
+ with self.assertRaises(ValueError) as e:
+ _strptime._strptime_time('19', '%Y %')
+ self.assertIs(e.exception.__suppress_context__, True)
def test_unconverteddata(self):
# Check ValueError is raised when there is unconverted data
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index f3643b6..44bcb94 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -198,6 +198,10 @@ class TimeTestCase(unittest.TestCase):
with self.assertRaises(ValueError) as e:
time.strptime('', '%D')
self.assertIs(e.exception.__suppress_context__, True)
+ # additional check for IndexError branch (issue #19545)
+ with self.assertRaises(ValueError) as e:
+ time.strptime('19', '%Y %')
+ self.assertIs(e.exception.__suppress_context__, True)
def test_asctime(self):
time.asctime(time.gmtime(self.t))