MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / record_module_exec

Function record_module_exec

asyncpg/protocol/record/recordobj.c:1164–1203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1162static PyMethodDef record_module_methods[] = {{NULL, NULL, 0, NULL}};
1163
1164static int
1165record_module_exec(PyObject *module)
1166{
1167 record_module_state *state = get_module_state(module);
1168 if (state == NULL) {
1169 return -1;
1170 }
1171
1172 if (PyThread_tss_create(&state->freelist_key) != 0) {
1173 PyErr_SetString(
1174 PyExc_SystemError,
1175 "failed to create TSS key for record freelist");
1176 return -1;
1177 }
1178
1179#define CREATE_TYPE(m, tp, spec) \
1180 do { \
1181 tp = (PyTypeObject *)PyType_FromModuleAndSpec(m, spec, NULL); \
1182 if (tp == NULL) \
1183 goto error; \
1184 if (PyModule_AddType(m, tp) < 0) \
1185 goto error; \
1186 } while (0)
1187
1188 CREATE_TYPE(module, state->ApgRecord_Type, &ApgRecord_TypeSpec);
1189 CREATE_TYPE(module, state->ApgRecordDesc_Type, &ApgRecordDesc_TypeSpec);
1190 CREATE_TYPE(module, state->ApgRecordIter_Type, &ApgRecordIter_TypeSpec);
1191 CREATE_TYPE(module, state->ApgRecordItems_Type, &ApgRecordItems_TypeSpec);
1192
1193#undef CREATE_TYPE
1194
1195 return 0;
1196
1197error:
1198 Py_CLEAR(state->ApgRecord_Type);
1199 Py_CLEAR(state->ApgRecordDesc_Type);
1200 Py_CLEAR(state->ApgRecordIter_Type);
1201 Py_CLEAR(state->ApgRecordItems_Type);
1202 return -1;
1203}
1204
1205static int
1206record_module_traverse(PyObject *module, visitproc visit, void *arg)

Callers

nothing calls this directly

Calls 1

get_module_stateFunction · 0.85

Tested by

no test coverage detected