Bug report
Bug description:
PyObject_IsTrue(tz_str) is used directly as a condition, so a -1 return counts as true and the exception is carried into a successful return:
|
if (tz_str != Py_None && PyObject_IsTrue(tz_str)) { |
PyLong_AsSsize_t() is checked with == -1 but without PyErr_Occurred(), so a transition index of -1 takes the error path with no exception set (although technically not reachable from a TZif file, since _common.load_data() unpacks the indices as unsigned bytes):
|
Py_ssize_t cur_trans_idx = PyLong_AsSsize_t(num); |
|
if (cur_trans_idx == -1) { |
|
goto error; |
|
} |
Found by @devdanzin ❤️
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Bug report
Bug description:
PyObject_IsTrue(tz_str)is used directly as a condition, so a -1 return counts as true and the exception is carried into a successful return:cpython/Modules/_zoneinfo.c
Line 1184 in 20e6c2f
PyLong_AsSsize_t()is checked with== -1but withoutPyErr_Occurred(), so a transition index of -1 takes the error path with no exception set (although technically not reachable from a TZif file, since_common.load_data()unpacks the indices as unsigned bytes):cpython/Modules/_zoneinfo.c
Lines 1072 to 1075 in 20e6c2f
Found by @devdanzin ❤️
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
_zoneinfo.load_data()#156068