Skip to content

Commit

Permalink
Add helpful message when passed bytes to gettz
Browse files Browse the repository at this point in the history
  • Loading branch information
labrys authored and pganssle committed Nov 2, 2019
1 parent 27848c5 commit d8cc4cc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions dateutil/tz/tz.py
Expand Up @@ -1615,8 +1615,15 @@ def nocache(name=None):
else:
tz = tzlocal()
else:
if name.startswith(":"):
name = name[1:]
try:
if name.startswith(":"):
name = name[1:]
except TypeError as e:
if isinstance(name, bytes):
new_msg = "gettz argument should be str, not bytes"
six.raise_from(TypeError(new_msg), e)
else:
raise
if os.path.isabs(name):
if os.path.isfile(name):
tz = tzfile(name)
Expand Down

0 comments on commit d8cc4cc

Please sign in to comment.