Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
use PySequence_GetItem instead of PyTuple_GetItem for better error ha…
…ndling
  • Loading branch information
blhsing committed Aug 23, 2024
commit c9c51d766f6ad37ea7ac98868fb4509b9dd469ee
6 changes: 2 additions & 4 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1961,14 +1961,12 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
#endif
) {
/* 0-pad year with century as necessary */
if (!PyTuple_Check(timetuple)) {
goto Done;
}
PyObject *item = PyTuple_GetItem(timetuple, 0);
PyObject *item = PySequence_GetItem(timetuple, 0);
if (item == NULL) {
goto Done;
}
long year_long = PyLong_AsLong(item);
Py_DECREF(item);
if (year_long == -1 && PyErr_Occurred()) {
goto Done;
}
Expand Down