diff options
author | jarondl <me@jarondl.net> | 2015-07-12 12:31:33 +0300 |
---|---|---|
committer | jarondl <me@jarondl.net> | 2015-07-12 12:31:33 +0300 |
commit | 51424458eca13b81f6624dcb121531c2b83572eb (patch) | |
tree | 35554428b02ec68ef14d920c92176a6d0cf86f7b | |
parent | 4bafd1a61d312ec5646190a9b2d66f04002fcdcd (diff) | |
download | dateutil-51424458eca13b81f6624dcb121531c2b83572eb.tar.gz |
Fix tzwin encoding errors
Stop encoding `_dstname` and `_stdname` to bytes with `iso-8859-1`, because we cannot assume that's the
correct codepage. Uses the current solution we use in `tz.py`, which outputs unicode in Python3.
Fixes #92 and http://stackoverflow.com/questions/21296475/python-dateutil-unicode-warning
and https://bugs.launchpad.net/dateutil/+bug/1227221
-rw-r--r-- | dateutil/tzwin.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/dateutil/tzwin.py b/dateutil/tzwin.py index e8a82d7..f4e0e24 100644 --- a/dateutil/tzwin.py +++ b/dateutil/tzwin.py @@ -4,6 +4,8 @@ import struct from six.moves import winreg +from .tz import tzname_in_python2 + __all__ = ["tzwin", "tzwinlocal"] ONEWEEK = datetime.timedelta(7) @@ -42,6 +44,7 @@ class tzwinbase(datetime.tzinfo): else: return datetime.timedelta(0) + @tzname_in_python2 def tzname(self, dt): if self._isdst(dt): return self._dstname @@ -89,8 +92,8 @@ class tzwin(tzwinbase): "%s\%s" % (TZKEYNAME, name)) as tzkey: keydict = valuestodict(tzkey) - self._stdname = keydict["Std"].encode("iso-8859-1") - self._dstname = keydict["Dlt"].encode("iso-8859-1") + self._stdname = keydict["Std"] + self._dstname = keydict["Dlt"] self._display = keydict["Display"] @@ -129,8 +132,8 @@ class tzwinlocal(tzwinbase): with winreg.OpenKey(handle, TZLOCALKEYNAME) as tzlocalkey: keydict = valuestodict(tzlocalkey) - self._stdname = keydict["StandardName"].encode("iso-8859-1") - self._dstname = keydict["DaylightName"].encode("iso-8859-1") + self._stdname = keydict["StandardName"] + self._dstname = keydict["DaylightName"] try: with winreg.OpenKey( |