diff --git a/apscheduler/util.py b/apscheduler/util.py index 6f70f921..d929a482 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 72c07fdb..8dc17480 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 2dffb247..55490fcb 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 f7f900b3..64ad2330 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')