Skip to content
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

PYTHON-3798 add error checking and visit for _type_marker_str #1291

Merged
merged 1 commit into from
Jul 6, 2023
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
5 changes: 4 additions & 1 deletion bson/_cbsonmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ static int _load_python_objects(PyObject* module) {
struct module_state *state = GETSTATE(module);

/* Python str for faster _type_marker check */
state->_type_marker_str = PyUnicode_FromString("_type_marker");
if (!(state->_type_marker_str = PyUnicode_FromString("_type_marker"))) {
return 1;
}

if (_load_object(&state->Binary, "bson.binary", "Binary") ||
_load_object(&state->Code, "bson.code", "Code") ||
Expand Down Expand Up @@ -3043,6 +3045,7 @@ static int _cbson_traverse(PyObject *m, visitproc visit, void *arg) {
Py_VISIT(GETSTATE(m)->MaxKey);
Py_VISIT(GETSTATE(m)->UTC);
Py_VISIT(GETSTATE(m)->REType);
Py_VISIT(GETSTATE(m)->_type_marker_str);
return 0;
}

Expand Down