summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-07-25 21:59:48 (GMT)
committerRaymond Hettinger <python@rcn.com>2014-07-25 21:59:48 (GMT)
commit5a2146a2fdb9b8adf6472f1bedbba68c41bab232 (patch)
tree0617249197e601d5cf56f982c78234593d54b46d /Lib
parent65dd69a3da16257bd86b92900e5ec5a8dd26f1d9 (diff)
downloadcpython-5a2146a2fdb9b8adf6472f1bedbba68c41bab232.zip
cpython-5a2146a2fdb9b8adf6472f1bedbba68c41bab232.tar.gz
cpython-5a2146a2fdb9b8adf6472f1bedbba68c41bab232.tar.bz2
Issue #22044: Fixed premature DECREF in call_tzinfo_method.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/datetimetester.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 3f3c60a..cf496b4 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -5,6 +5,7 @@ See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
import sys
import pickle
+import random
import unittest
from operator import lt, le, gt, ge, eq, ne, truediv, floordiv, mod
@@ -76,8 +77,18 @@ class PicklableFixedOffset(FixedOffset):
def __init__(self, offset=None, name=None, dstoffset=None):
FixedOffset.__init__(self, offset, name, dstoffset)
+class _TZInfo(tzinfo):
+ def utcoffset(self, datetime_module):
+ return random.random()
+
class TestTZInfo(unittest.TestCase):
+ def test_refcnt_crash_bug_22044(self):
+ tz1 = _TZInfo()
+ dt1 = datetime(2014, 7, 21, 11, 32, 3, 0, tz1)
+ with self.assertRaises(TypeError):
+ dt1.utcoffset()
+
def test_non_abstractness(self):
# In order to allow subclasses to get pickled, the C implementation
# wasn't able to get away with having __init__ raise