bpo-29953: Fix memory leaks in the replace() method of datetime and time (#927)

objects when pass out of bound fold argument.
This commit is contained in:
Serhiy Storchaka 2017-03-31 22:48:16 +03:00 committed by GitHub
parent 06bb4873d6
commit 314d6fca36
3 changed files with 18 additions and 11 deletions

View file

@ -4313,6 +4313,11 @@ class TestLocalTimeDisambiguation(unittest.TestCase):
dt = dt.replace(fold=1, tzinfo=Eastern)
self.assertEqual(t.replace(tzinfo=None).fold, 1)
self.assertEqual(dt.replace(tzinfo=None).fold, 1)
# Out of bounds.
with self.assertRaises(ValueError):
t.replace(fold=2)
with self.assertRaises(ValueError):
dt.replace(fold=2)
# Check that fold is a keyword-only argument
with self.assertRaises(TypeError):
t.replace(1, 1, 1, None, 1)