Skip to content

tz.gettz broken when passed non-ASCII string on Windows for Python 2.7 #802

@pganssle

Description

@pganssle

Related to #800, running this on Windows with Python 2.7:

from dateutil import tz
tz.gettz('🐼')

Raises an error:

self = tzwin(u'\U0001f43c'), name = '🐼'
    def __init__(self, name):
        self._name = name
    
        with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
            tzkeyname = text_type("{kn}\\{name}").format(kn=TZKEYNAME, name=name)
>           with winreg.OpenKey(handle, tzkeyname) as tzkey:
E           UnicodeEncodeError: 'ascii' codec can't encode characters in position 56-57: ordinal not in range(128)
dateutil\tz\win.py:220: UnicodeEncodeError

Even if tz.tzwin doesn't support unicode names, tz.gettz should not be raising an error in this situation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions