Skip to content
Closed
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
Next Next commit
_datetimemodule._check_invalid_datetime_specs only accepts tuple and not
list
  • Loading branch information
matrixise committed Mar 24, 2019
commit a952bb7077f43f6e97f1ae28eb8ecb9814a26060
7 changes: 2 additions & 5 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -6360,18 +6360,15 @@ _check_invalid_datetime_specs(PyObject *module, PyObject *args)
return NULL;
}

assert(PyTuple_CheckExact(specs) || PyList_CheckExact(specs));
assert(PyTuple_Check(specs));

PyObject *found_invalid_specs = PyList_New(0);
if (found_invalid_specs == NULL) {
return NULL;
}

PyObject *(*GetItem)(PyObject *, Py_ssize_t) = \
PyTuple_CheckExact(specs) ? PyTuple_GetItem : PyList_GetItem;

for (Py_ssize_t pos = 0; pos < PyObject_Size(specs); pos++) {
PyObject *spec = GetItem(specs, pos);
PyObject *spec = PyTuple_GetItem(specs, pos);
if (PySequence_Contains(format, spec)) {
PyList_Append(found_invalid_specs, spec);
}
Expand Down