Code Sample, a copy-pastable example if possible
import win32timezone
import pywintypes
import pandas
d = pywintypes.TimeType(2001, 1, 1, tzinfo=win32timezone.TimeZoneInfo('Eastern Standard Time'))
ix = pandas.Index([d]) ## crash occurs here
Problem description
In the example above, tzinfo.utcoffset(None) returns None. In tslib.pyx _get_dst_info calls int(total_seconds(_get_utcoffset(tz, None))), and _get_utcoffset(tz, None) returns None. This causes a hard crash because total_seconds from datetime_helper.h expects a timedelta object, and crashes if the attributes "microseconds", "seconds" or "days" don't exist.
// from datetime_helper.h
npy_int64 get_long_attr(PyObject *o, const char *attr) {
npy_int64 long_val;
PyObject *value = PyObject_GetAttrString(o, attr); <-- This returns NULL
When using a timezone from pytz the _utcoffset attribute is set, which is used by _get_utcoffset, and so this crash doesn't happen with that library.
Expected Output
It shouldn't crash. Ideally it would handle these timezone types, but at least it should raise an Exception if the timezone type isn't currently supported.
Output of pd.show_versions()
Comment From: jreback
duplicate of #10459
if you want to submit a PR to make this raise NotImplementedError
as suggested in that issue great. These are not accepted by pandas, nor do these timezone objects follow the specifications.