Skip to content
Merged
Changes from all commits
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
8 changes: 5 additions & 3 deletions bson/_cbsonmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1657,10 +1657,10 @@ void handle_invalid_doc_error(PyObject* dict) {
}

if (evalue && PyErr_GivenExceptionMatches(etype, InvalidDocument)) {
PyObject *msg = PyObject_Str(evalue);
msg = PyObject_Str(evalue);
if (msg) {
// Prepend doc to the existing message
PyObject *dict_str = PyObject_Str(dict);
dict_str = PyObject_Str(dict);
if (dict_str == NULL) {
goto cleanup;
}
Expand All @@ -1672,15 +1672,17 @@ void handle_invalid_doc_error(PyObject* dict) {
if (msg_utf8 == NULL) {
goto cleanup;
}
PyObject *new_msg = PyUnicode_FromFormat("Invalid document %s | %s", dict_str_utf8, msg_utf8);
new_msg = PyUnicode_FromFormat("Invalid document %s | %s", dict_str_utf8, msg_utf8);
Py_DECREF(evalue);
Py_DECREF(etype);
etype = InvalidDocument;
InvalidDocument = NULL;
if (new_msg) {
evalue = new_msg;
new_msg = NULL;
} else {
evalue = msg;
msg = NULL;
}
}
PyErr_NormalizeException(&etype, &evalue, &etrace);
Expand Down
Loading