diff options
author | Paul Ganssle <pganssle@users.noreply.github.com> | 2019-02-03 12:46:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-03 12:46:23 -0500 |
commit | b9aa7f0bf92961bfd91e36bbaff2d4c8c5abaf51 (patch) | |
tree | bacba89c979d553ece84827d5c9c881843f14b90 | |
parent | ee819bf84929cb24a549398a7b753f07f1ce4904 (diff) | |
parent | d353650ab29c81f79315ae249df7f96eb5c50e5d (diff) | |
download | dateutil-b9aa7f0bf92961bfd91e36bbaff2d4c8c5abaf51.tar.gz |
Merge pull request #861 from pganssle/fix_gettz_windows_unicode
Catch UnicodeEncodeError for Windows in tz.gettz
-rw-r--r-- | changelog.d/861.bugfix.rst | 1 | ||||
-rw-r--r-- | dateutil/test/test_tz.py | 2 | ||||
-rw-r--r-- | dateutil/tz/tz.py | 3 |
3 files changed, 3 insertions, 3 deletions
diff --git a/changelog.d/861.bugfix.rst b/changelog.d/861.bugfix.rst new file mode 100644 index 0000000..a4f9da2 --- /dev/null +++ b/changelog.d/861.bugfix.rst @@ -0,0 +1 @@ +Fixed error condition in ``tz.gettz`` when a non-ASCII timezone is passed on Windows in Python 2.7. (gh issue #802, pr #861) diff --git a/dateutil/test/test_tz.py b/dateutil/test/test_tz.py index 386b909..bb0f4b7 100644 --- a/dateutil/test/test_tz.py +++ b/dateutil/test/test_tz.py @@ -1095,8 +1095,6 @@ def test_gettz_badzone(badzone): @pytest.mark.gettz -@pytest.mark.xfail(IS_WIN and PY2, - reason='tzwin fails with non-unicode characters on 2.7') def test_gettz_badzone_unicode(): # Make sure a unicode string can be passed to TZ (GH #802) # When fixed, combine this with test_gettz_badzone diff --git a/dateutil/tz/tz.py b/dateutil/tz/tz.py index 161f4d8..d05414e 100644 --- a/dateutil/tz/tz.py +++ b/dateutil/tz/tz.py @@ -1633,7 +1633,8 @@ def __get_gettz(): if tzwin is not None: try: tz = tzwin(name) - except WindowsError: + except (WindowsError, UnicodeEncodeError): + # UnicodeEncodeError is for Python 2.7 compat tz = None if not tz: |