Skip to content

Commit

Permalink
Fix incorrect import in Python 3.7+
Browse files Browse the repository at this point in the history
It turns out that the import of `contextlib.nullcontext` in Python 3.7+
was accidentally trying to import `contextmanager.nullcontext`, but this
was never noticed because it simply fell back to the backport included
here.

I do not know of a great way to test this that doesn't rely on
implementation details, but I have manually tested it by setting a
breakpoint after the import in the `try` statement and importing
`dateutil.tz` manually on Python 3.7, so this version should work.
  • Loading branch information
pganssle committed Sep 22, 2019
1 parent 22b43cb commit 7a32e5a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dateutil/tz/tz.py
Expand Up @@ -1823,7 +1823,7 @@ def _get_supported_offset(second_offset):

try:
# Python 3.7 feature
from contextmanager import nullcontext as _nullcontext
from contextlib import nullcontext as _nullcontext
except ImportError:
class _nullcontext(object):
"""
Expand Down

0 comments on commit 7a32e5a

Please sign in to comment.