Join GitHub today
Bug: tslib.tz_convert(vals, tz1, tz2) may raise an IndexError exception. #4496
The following code produces "Out of bounds on buffer access (axis 0)" exception when accessing idx.hour:
import pandas as pd
idx = pd.date_range('26/3/2011', '27/3/2011', freq='1min')
hour = idx.hour
Traceback (most recent call last):
My research indicated there was a bug in the following piece of code in tslib.tz_convert(vals, tz1, tz2) in Pandas 0.12. There is no check that "(pos + 1) < len(trans)" when referencing trans[pos + 1] inside the for loop:
As a result in some circumstances this code raises "Out of bounds on buffer access (axis 0)" exception. For example, in Russia last day-light saving transition took place in somewhere in 26/3/2011-27/3/2011, and there were no transitions since then.
If ts_lib.tz_convert() is asked to convert time zones for interval that includes 26/3/2011-27/3/2011, it raises an exception while trying to access trans[pos + 1].
I have a working patch that solves this. Going to contribute it soon.