As reported at pendulum, there are cases where creating a date_range
fails with a segfault: pendulum issues 131.
Code Sample
from datetime import datetime, timedelta
from pendulum.tz.timezone import UTCTimezone
from pendulum.tz.timezone_info import UTC
import pandas as pd
tomorrow = datetime.now() + timedelta(hours=24)
now = datetime.now()
r = pd.date_range(now, tomorrow, freq='1H')
r.tz = UTC
# prints out the current date and time
print(r[0])
r.tz = UTCTimezone
# seg faults
print(r[0])
Problem description
As I understand it is allowed for tzinfo
objects to return None
for utcoffset
according to the Python docs. However, in _get_dst_info of tslib
it is assumed not to return None
. As I understand from the aforementioned pendulum
ticket, it is correct to return None
in this case.
Output of pd.show_versions()
Comment From: jreback
duplicate issue of https://github.com/pandas-dev/pandas/issues/15986, see discussion there.
Comment From: frensjan
@jreback sorry, missed that one. Still think that it would be good if pandas doesn't segfault on a valid response from a timezone object (valid as in that according to the python docs a timezone object is allowed to return None).
Comment From: jreback
@frensjan if you want to make a PR that uses a mock timezone object would be great.
Still think that it would be good if pandas doesn't segfault on a valid response from a timezone object (valid as in that according to the python docs a timezone object is allowed to return None).
I am not so sure that this library complies.