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
Next Next commit
Separate handling of Unicode and other errors
In the initial implementation, errors other than encoding errors would
both raise an error indicating an invalid format, which would not be
true for errors like MemoryError.
  • Loading branch information
pganssle committed Oct 21, 2018
commit 4e54bd90b1f587bdaccd3ed5ae3ce7915836949e
7 changes: 6 additions & 1 deletion Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4911,7 +4911,12 @@ datetime_fromisoformat(PyObject* cls, PyObject *dtstr) {
const char * dt_ptr = PyUnicode_AsUTF8AndSize(dtstr_clean, &len);

if (dt_ptr == NULL) {
goto invalid_string_error;
if (PyErr_ExceptionMatches(PyExc_UnicodeEncodeError)) {
// Encoding errors are invalid string errors at this point
goto invalid_string_error;
} else {
goto error;
}
}

const char *p = dt_ptr;
Expand Down