@@ -1029,6 +1029,10 @@ cdef inline object _get_zone(object tz):
1029
1029
return ' UTC'
1030
1030
else :
1031
1031
if _treat_tz_as_dateutil(tz):
1032
+ if ' .tar.gz' in tz._filename:
1033
+ raise ValueError (' Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all '
1034
+ ' timezone files. Please construct dateutil timezones implicitly by passing a string like "dateutil/Europe/London" '
1035
+ ' when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362' )
1032
1036
return ' dateutil/' + tz._filename
1033
1037
else :
1034
1038
# tz is a pytz timezone or unknown.
@@ -1048,7 +1052,11 @@ cpdef inline object maybe_get_tz(object tz):
1048
1052
'''
1049
1053
if isinstance (tz, string_types):
1050
1054
if tz.startswith(' dateutil/' ):
1055
+ zone = tz[9 :]
1051
1056
tz = _dateutil_gettz(tz[9 :])
1057
+ # On Python 3 on Windows, the filename is not always set correctly.
1058
+ if isinstance (tz, _dateutil_tzfile) and ' .tar.gz' in tz._filename:
1059
+ tz._filename = zone
1052
1060
else :
1053
1061
tz = pytz.timezone(tz)
1054
1062
return tz
@@ -1965,6 +1973,10 @@ cdef inline object _tz_cache_key(object tz):
1965
1973
if isinstance (tz, _pytz_BaseTzInfo):
1966
1974
return tz.zone
1967
1975
elif isinstance (tz, _dateutil_tzfile):
1976
+ if ' .tar.gz' in tz._filename:
1977
+ raise ValueError (' Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all '
1978
+ ' timezone files. Please construct dateutil timezones implicitly by passing a string like "dateutil/Europe/London" '
1979
+ ' when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362' )
1968
1980
return tz._filename
1969
1981
else :
1970
1982
return None
0 commit comments