mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
#17572: Avoid chained exceptions while passing bad directives to time.strptime(). Initial patch by Claudiu Popa.
This commit is contained in:
parent
a99e1711f7
commit
0f38908684
4 changed files with 16 additions and 1 deletions
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue