aboutsummaryrefslogtreecommitdiff
path: root/dateutil/tz/_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'dateutil/tz/_common.py')
-rw-r--r--dateutil/tz/_common.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/dateutil/tz/_common.py b/dateutil/tz/_common.py
index ccabb7d..594e082 100644
--- a/dateutil/tz/_common.py
+++ b/dateutil/tz/_common.py
@@ -1,4 +1,4 @@
-from six import PY3
+from six import PY2
from functools import wraps
@@ -16,14 +16,18 @@ def tzname_in_python2(namefunc):
tzname() API changed in Python 3. It used to return bytes, but was changed
to unicode strings
"""
- def adjust_encoding(*args, **kwargs):
- name = namefunc(*args, **kwargs)
- if name is not None and not PY3:
- name = name.encode()
-
- return name
-
- return adjust_encoding
+ if PY2:
+ @wraps(namefunc)
+ def adjust_encoding(*args, **kwargs):
+ name = namefunc(*args, **kwargs)
+ if name is not None:
+ name = name.encode()
+
+ return name
+
+ return adjust_encoding
+ else:
+ return namefunc
# The following is adapted from Alexander Belopolsky's tz library