8000 WIP: bpo-1100942: Add datetime.time.strptime and datetime.date.strptime by matrixise · Pull Request #5578 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

WIP: bpo-1100942: Add datetime.time.strptime and datetime.date.strptime #5578

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
wants to merge 16 commits into from
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
0