# HG changeset patch # User Paul Ganssle <paul@ganssle.io> # Date 1525824722 14400 # Tue May 08 20:12:02 2018 -0400 # Node ID 7c16a4a3ce300c02acb28c36d5aa5349bc8c830c # Parent 84fac24f3418200e0420d8586e6d78edf424ef47 Revert "Add tests for weak references in timezone caches" This reverts commit b5d8b854bfea421f6185b0d332a2524b355bfbdc. diff --git a/dateutil/test/test_tz.py b/dateutil/test/test_tz.py --- a/dateutil/test/test_tz.py +++ b/dateutil/test/test_tz.py @@ -14,7 +14,6 @@ import sys import base64 import copy -import gc from functools import partial @@ -732,20 +731,6 @@ assert tz1 is tz2 - def testTzOffsetWeakRef(self): - UTC1 = tz.tzoffset('UTC', 0) - UTC2 = tz.tzoffset('UTC', 0) - assert id(UTC1) == id(UTC2) - - weak_ref_id = id(UTC1) - del UTC1 - del UTC2 - gc.collect() - - UTC3 = tz.tzoffset('UTC', 0) - assert not weak_ref_id == id(UTC3) - - @pytest.mark.tzoffset @pytest.mark.parametrize('args', [ ('UTC', 0), @@ -1052,21 +1037,6 @@ assert local1 is not local2 - def testGettzWeakRef(self): - tz.gettz.cache_clear() - NYC1 = tz.gettz('America/New_York') - NYC2 = tz.gettz('America/New_York') - assert id(NYC1) == id(NYC2) - - weak_ref_id = id(NYC1) - del NYC1 - del NYC2 - gc.collect() - - NYC3 = tz.gettz('America/New_York') - assert not weak_ref_id == id(NYC3) - - @pytest.mark.gettz @pytest.mark.xfail(IS_WIN, reason='zoneinfo separately cached') def test_gettz_cache_clear(): @@ -1405,20 +1375,6 @@ # Ensure that these still are all the same zone assert tz1 == tz2 == tz3 - def testTzOffsetWeakRef(self): - tz_t1 = tz.tzstr('EST5EDT') - tz_t2 = tz.tzstr('EST5EDT') - assert id(tz_t1) == id(tz_t2) - - weak_ref_id = id(tz_t1) - del tz_t1 - del tz_t2 - gc.collect() - - tz_t3 = tz.tzstr('EST5EDT') - assert not weak_ref_id == id(tz_t3) - - @pytest.mark.tzstr @pytest.mark.parametrize('tz_str,expected', [ # From https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html diff --git a/dateutil/tz/tz.py b/dateutil/tz/tz.py --- a/dateutil/tz/tz.py +++ b/dateutil/tz/tz.py @@ -1548,7 +1548,7 @@ def cache_clear(self): with self._cache_lock: - self.__instances = weakref.WeakValueDictionary() + self.__instances = {} @staticmethod def nocache(name=None):