コード例 #1
0
/* Reload all cached Python objects.
 *
 * Returns non-zero on failure. */
static int _reload_python_objects(void) {
    if (_reload_object(&Binary, "bson.binary", "Binary") ||
        _reload_object(&Code, "bson.code", "Code") ||
        _reload_object(&ObjectId, "bson.objectid", "ObjectId") ||
        _reload_object(&DBRef, "bson.dbref", "DBRef") ||
        _reload_object(&Timestamp, "bson.timestamp", "Timestamp") ||
        _reload_object(&MinKey, "bson.min_key", "MinKey") ||
        _reload_object(&MaxKey, "bson.max_key", "MaxKey") ||
        _reload_object(&UTC, "bson.tz_util", "utc") ||
        _reload_object(&RECompile, "re", "compile")) {
        return 1;
    }
    /* If we couldn't import uuid then we must be on 2.4. Just ignore. */
    if (_reload_object(&UUID, "uuid", "UUID") == 1) {
        UUID = NULL;
        PyErr_Clear();
    }
    /* Reload our REType hack too. */
    REType = PyObject_CallFunction(RECompile, "O",
                                   PyString_FromString(""))->ob_type;
    return 0;
}
コード例 #2
0
/* Reload all cached Python objects.
 *
 * Returns non-zero on failure. */
static int _reload_python_objects(PyObject* self) {
    struct module_state *state = GETSTATE(self);

    if (_reload_object(&state->Binary, "bson.binary", "Binary") ||
        _reload_object(&state->Code, "bson.code", "Code") ||
        _reload_object(&state->ObjectId, "bson.objectid", "ObjectId") ||
        _reload_object(&state->DBRef, "bson.dbref", "DBRef") ||
        _reload_object(&state->Timestamp, "bson.timestamp", "Timestamp") ||
        _reload_object(&state->MinKey, "bson.min_key", "MinKey") ||
        _reload_object(&state->MaxKey, "bson.max_key", "MaxKey") ||
        _reload_object(&state->UTC, "bson.tz_util", "utc") ||
        _reload_object(&state->RECompile, "re", "compile")) {
        return 1;
    }
    /* If we couldn't import uuid then we must be on 2.4. Just ignore. */
    if (_reload_object(&state->UUID, "uuid", "UUID") == 1) {
        state->UUID = NULL;
        PyErr_Clear();
    }
    /* Reload our REType hack too. */
    state->REType = PyObject_CallFunction(state->RECompile, "O",
                                          PyString_FromString(""))->ob_type;
    return 0;
}