Skip to content

date_range segfaults on None utcoffset #16885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
frensjan opened this issue Jul 11, 2017 · 3 comments
Closed

date_range segfaults on None utcoffset #16885

frensjan opened this issue Jul 11, 2017 · 3 comments
Labels
Duplicate Report Duplicate issue or pull request Timezones Timezone data dtype

Comments

@frensjan
Copy link

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()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.3.final.0 python-bits: 64 OS: Linux OS-release: 4.11.3-200.fc25.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8

pandas: 0.20.3
pytest: 3.1.3
pip: 9.0.1
setuptools: 25.1.1
Cython: None
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: 6.1.0
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
pandas_gbq: None
pandas_datareader: None

@jreback
Copy link
Contributor

jreback commented Jul 12, 2017

duplicate issue of #15986, see discussion there.

@jreback jreback closed this as completed Jul 12, 2017
@jreback jreback added Duplicate Report Duplicate issue or pull request Timezones Timezone data dtype labels Jul 12, 2017
@jreback jreback added this to the No action milestone Jul 12, 2017
@frensjan
Copy link
Author

@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).

@jreback
Copy link
Contributor

jreback commented Jul 12, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Timezones Timezone data dtype
Projects
None yet
Development

No branches or pull requests

2 participants