bson/_cbsonmodule.c
/* Load all Python objects to cache.
 *
 * Returns non-zero on failure. */
Load all Python objects to cache.
Returns non-zero on failure.
Load all Python objects to cache . Returns non - zero on failure .
static int _load_python_objects(PyObject* module) {
    PyObject* empty_string;
    PyObject* compiled;
    struct module_state *state = GETSTATE(module);
    if (_load_object(&state->Binary, "bson.binary", "Binary") ||
        _load_object(&state->Code, "bson.code", "Code") ||
        _load_object(&state->ObjectId, "bson.objectid", "ObjectId") ||
        _load_object(&state->DBRef, "bson.dbref", "DBRef") ||
        _load_object(&state->Timestamp, "bson.timestamp", "Timestamp") ||
        _load_object(&state->MinKey, "bson.min_key", "MinKey") ||
        _load_object(&state->MaxKey, "bson.max_key", "MaxKey") ||
        _load_object(&state->UTC, "bson.tz_util", "utc") ||
        _load_object(&state->RECompile, "re", "compile") ||
        _load_object(&state->Regex, "bson.regex", "Regex")) {
        return 1;
    }
    if (_load_object(&state->UUID, "uuid", "UUID") == 1) {
        state->UUID = NULL;
        PyErr_Clear();
    }
#if PY_MAJOR_VERSION >= 3
    empty_string = PyBytes_FromString("");
#else
    empty_string = PyString_FromString("");
#endif
    if (empty_string == NULL) {
        state->REType = NULL;
        return 1;
    }
    compiled = PyObject_CallFunction(state->RECompile, "O", empty_string);
    if (compiled == NULL) {
        state->REType = NULL;
        Py_DECREF(empty_string);
        return 1;
    }
    Py_INCREF(Py_TYPE(compiled));
    state->REType = Py_TYPE(compiled);
    Py_DECREF(empty_string);
    Py_DECREF(compiled);
    return 0;
}
static int _load_python_objects ( PyObject * module ) { PyObject * empty_string ; PyObject * compiled ; struct module_state * state = GETSTATE ( module ) ; if ( _load_object ( & state -> Binary , " " , " " ) || _load_object ( & state -> Code , " " , " " ) || _load_object ( & state -> ObjectId , " " , " " ) || _load_object ( & state -> DBRef , " " , " " ) || _load_object ( & state -> Timestamp , " " , " " ) || _load_object ( & state -> MinKey , " " , " " ) || _load_object ( & state -> MaxKey , " " , " " ) || _load_object ( & state -> UTC , " " , " " ) || _load_object ( & state -> RECompile , " " , " " ) || _load_object ( & state -> Regex , " " , " " ) ) { return 1 ; } if ( _load_object ( & state -> UUID , " " , " " ) == 1 ) { state -> UUID = NULL ; PyErr_Clear ( ) ; } #if PY_MAJOR_VERSION >= 3 empty_string = PyBytes_FromString ( " " ) ; #else empty_string = PyString_FromString ( " " ) ; #endif if ( empty_string == NULL ) { state -> REType = NULL ; return 1 ; } compiled = PyObject_CallFunction ( state -> RECompile , " " , empty_string ) ; if ( compiled == NULL ) { state -> REType = NULL ; Py_DECREF ( empty_string ) ; return 1 ; } Py_INCREF ( Py_TYPE ( compiled ) ) ; state -> REType = Py_TYPE ( compiled ) ; Py_DECREF ( empty_string ) ; Py_DECREF ( compiled ) ; return 0 ; }
Load all Python objects to cache.
Load all Python objects to cache .
/* If we couldn't import uuid then we must be on 2.4. Just ignore. */ /* Reload our REType hack too. */