| 1090 | } |
| 1091 | |
| 1092 | static PyObject * |
| 1093 | record_desc_make_record(PyObject *desc, PyTypeObject *desc_type, |
| 1094 | PyObject *const *args, Py_ssize_t nargs, |
| 1095 | PyObject *kwnames) |
| 1096 | { |
| 1097 | PyObject *type_obj; |
| 1098 | Py_ssize_t size; |
| 1099 | record_module_state *state = get_module_state_from_type(desc_type); |
| 1100 | |
| 1101 | if (state == NULL) { |
| 1102 | return NULL; |
| 1103 | } |
| 1104 | |
| 1105 | if (nargs != 2) { |
| 1106 | PyErr_Format(PyExc_TypeError, |
| 1107 | "RecordDescriptor.make_record() takes exactly 2 arguments (%zd given)", |
| 1108 | nargs); |
| 1109 | return NULL; |
| 1110 | } |
| 1111 | |
| 1112 | if (kwnames != NULL && PyTuple_GET_SIZE(kwnames) != 0) { |
| 1113 | PyErr_SetString(PyExc_TypeError, |
| 1114 | "RecordDescriptor.make_record() takes no keyword arguments"); |
| 1115 | return NULL; |
| 1116 | } |
| 1117 | |
| 1118 | type_obj = args[0]; |
| 1119 | size = PyLong_AsSsize_t(args[1]); |
| 1120 | if (size == -1 && PyErr_Occurred()) { |
| 1121 | return NULL; |
| 1122 | } |
| 1123 | |
| 1124 | if (!PyType_Check(type_obj)) { |
| 1125 | PyErr_SetString(PyExc_TypeError, |
| 1126 | "RecordDescriptor.make_record(): first argument must be a type"); |
| 1127 | return NULL; |
| 1128 | } |
| 1129 | |
| 1130 | return make_record((PyTypeObject *)type_obj, desc, size, state); |
| 1131 | } |
| 1132 | |
| 1133 | static PyMethodDef record_desc_methods[] = { |
| 1134 | {"make_record", _PyCFunction_CAST(record_desc_make_record), |
nothing calls this directly
no test coverage detected