From a5e2cadb8a60ded5b57169e0c080782e976dc99b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Sun, 27 Feb 2022 17:42:18 +0200 Subject: [PATCH] Removed a leftover check for pytz timezones Fixes #599. --- apscheduler/util.py | 2 -- docs/migration.rst | 1 + docs/versionhistory.rst | 6 ++++++ tests/test_util.py | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apscheduler/util.py b/apscheduler/util.py index 6f70f921b..d929a4822 100644 --- a/apscheduler/util.py +++ b/apscheduler/util.py @@ -90,8 +90,6 @@ def astimezone(obj): if isinstance(obj, six.string_types): return timezone(obj) if isinstance(obj, tzinfo): - if not hasattr(obj, 'localize') or not hasattr(obj, 'normalize'): - raise TypeError('Only timezones from the pytz library are supported') if obj.tzname(None) == 'local': raise ValueError( 'Unable to determine the name of the local timezone -- you must explicitly ' diff --git a/docs/migration.rst b/docs/migration.rst index 72c07fdb2..8dc17480c 100644 --- a/docs/migration.rst +++ b/docs/migration.rst @@ -68,6 +68,7 @@ but if you were instantiating triggers manually before, then one must be supplie The only other backwards incompatible change was that ``get_next_fire_time()`` takes two arguments now: the previous fire time and the current datetime. +.. note:: APScheduler 3.9.0 added experimental support for non-pytz timezones. From v1.x to 2.0 ================ diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst index 2dffb2478..55490fcba 100644 --- a/docs/versionhistory.rst +++ b/docs/versionhistory.rst @@ -4,6 +4,12 @@ Version history To find out how to migrate your application from a previous version of APScheduler, see the :doc:`migration section `. +3.9.1 +----- + +* Removed a leftover check for pytz ``localize()`` and ``normalize()`` methods + + 3.9.0 ----- diff --git a/tests/test_util.py b/tests/test_util.py index f7f900b34..64ad23300 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -94,8 +94,8 @@ def test_none(self): assert astimezone(None) is None def test_bad_timezone_type(self): - exc = pytest.raises(TypeError, astimezone, tzinfo()) - assert 'Only timezones from the pytz library are supported' in str(exc.value) + pytest.raises(NotImplementedError, astimezone, tzinfo()).\ + match(r'(a )?tzinfo subclass must (implement|override) tzname\(\)') def test_bad_local_timezone(self): zone = Mock(tzinfo, localize=None, normalize=None, tzname=lambda dt: 'local')