@@ -1029,6 +1029,10 @@ cdef inline object _get_zone(object tz):
10291029 return ' UTC'
10301030 else :
10311031 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' )
10321036 return ' dateutil/' + tz._filename
10331037 else :
10341038 # tz is a pytz timezone or unknown.
@@ -1048,7 +1052,11 @@ cpdef inline object maybe_get_tz(object tz):
10481052 '''
10491053 if isinstance (tz, string_types):
10501054 if tz.startswith(' dateutil/' ):
1055+ zone = tz[9 :]
10511056 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
10521060 else :
10531061 tz = pytz.timezone(tz)
10541062 return tz
@@ -1965,6 +1973,10 @@ cdef inline object _tz_cache_key(object tz):
19651973 if isinstance (tz, _pytz_BaseTzInfo):
19661974 return tz.zone
19671975 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' )
19681980 return tz._filename
19691981 else :
19701982 return None
0 commit comments