Skip to content

Commit

Permalink
Removed a leftover check for pytz timezones
Browse files Browse the repository at this point in the history
Fixes #599.
  • Loading branch information
agronholm committed Feb 27, 2022
1 parent f126487 commit a5e2cad
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 0 additions & 2 deletions apscheduler/util.py
Expand Up @@ -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 '
Expand Down
1 change: 1 addition & 0 deletions docs/migration.rst
Expand Up @@ -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
================
Expand Down
6 changes: 6 additions & 0 deletions docs/versionhistory.rst
Expand Up @@ -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 <migration>`.

3.9.1
-----

* Removed a leftover check for pytz ``localize()`` and ``normalize()`` methods


3.9.0
-----

Expand Down
4 changes: 2 additions & 2 deletions tests/test_util.py
Expand Up @@ -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')
Expand Down

0 comments on commit a5e2cad

Please sign in to comment.