summaryrefslogtreecommitdiff
path: root/Lib/test/test_strptime.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
commit69a9ce87abf6eee46ef3d434ec1c120ee6e02ee4 (patch)
tree8e0b7b0c0cbad2a685628715268625da40dcb575 /Lib/test/test_strptime.py
parentfb91ce666cfcfce35b37260436106644919737d4 (diff)
downloadcpython-69a9ce87abf6eee46ef3d434ec1c120ee6e02ee4.tar.gz
#17572: Avoid chained exceptions while passing bad directives to time.strptime(). Initial patch by Claudiu Popa.
Diffstat (limited to 'Lib/test/test_strptime.py')
-rw-r--r--Lib/test/test_strptime.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 90aac5b3f6..68e6a67636 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -218,6 +218,12 @@ class StrptimeTests(unittest.TestCase):
else:
self.fail("'%s' did not raise ValueError" % bad_format)
+ def test_strptime_exception_context(self):
+ # check that this doesn't chain exceptions needlessly (see #17572)
+ with self.assertRaises(ValueError) as e:
+ _strptime._strptime_time('', '%D')
+ self.assertIs(e.exception.__suppress_context__, True)
+
def test_unconverteddata(self):
# Check ValueError is raised when there is unconverted data
self.assertRaises(ValueError, _strptime._strptime_time, "10 12", "%m")