Skip to content

Commit

Permalink
PYTHON-3798 add error checking and visit for _type_marker_str (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyStick committed Jul 6, 2023
1 parent 32b2b32 commit c7432db
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit c7432db

Please sign in to comment.