Issue #19545: Avoid chained exceptions while passing stray % to

time.strptime().  Initial patch by Claudiu Popa.
This commit is contained in:
Serhiy Storchaka 2013-11-24 18:17:11 +02:00
commit b5d386314f
4 changed files with 12 additions and 1 deletions

View file

@ -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))