diff --git a/bson/_cbsonmodule.c b/bson/_cbsonmodule.c index bdd987e53..d912524f4 100644 --- a/bson/_cbsonmodule.c +++ b/bson/_cbsonmodule.c @@ -1040,9 +1040,11 @@ static PyObject* _cbson_dict_to_bson(PyObject* self, PyObject* args) { PyObject* result; unsigned char check_keys; unsigned char uuid_subtype; + unsigned char top_level = 1; buffer_t buffer; - if (!PyArg_ParseTuple(args, "Obb", &dict, &check_keys, &uuid_subtype)) { + if (!PyArg_ParseTuple(args, "Obb|b", &dict, + &check_keys, &uuid_subtype, &top_level)) { return NULL; } @@ -1052,7 +1054,7 @@ static PyObject* _cbson_dict_to_bson(PyObject* self, PyObject* args) { return NULL; } - if (!write_dict(self, buffer, dict, check_keys, uuid_subtype, 1)) { + if (!write_dict(self, buffer, dict, check_keys, uuid_subtype, top_level)) { buffer_free(buffer); return NULL; }