summaryrefslogtreecommitdiff
path: root/Lib/test/test_time.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-04-04 02:09:20 +0300
committerEzio Melotti <ezio.melotti@gmail.com>2013-04-04 02:09:20 +0300
commit0f38908684505905fd0890f4effbe6f683b39954 (patch)
treeb38d916a07ecd6e6cefd10ccb0fea619f0e2d172 /Lib/test/test_time.py
parenta99e1711f7899fa49dfde4cd6b7514ad172ddff2 (diff)
downloadcpython-git-0f38908684505905fd0890f4effbe6f683b39954.tar.gz
#17572: Avoid chained exceptions while passing bad directives to time.strptime(). Initial patch by Claudiu Popa.
Diffstat (limited to 'Lib/test/test_time.py')
-rw-r--r--Lib/test/test_time.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index da0f555d91..0e4d70284b 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -193,6 +193,12 @@ class TimeTestCase(unittest.TestCase):
self.assertRaises(TypeError, time.strptime, b'2009', "%Y")
self.assertRaises(TypeError, time.strptime, '2009', b'%Y')
+ def test_strptime_exception_context(self):
+ # check that this doesn't chain exceptions needlessly (see #17572)
+ with self.assertRaises(ValueError) as e:
+ time.strptime('', '%D')
+ self.assertIs(e.exception.__suppress_context__, True)
+
def test_asctime(self):
time.asctime(time.gmtime(self.t))