@@ -30,6 +30,7 @@ record_desc_dealloc(EdgeRecordDescObject *o)
3030 PyObject_GC_UnTrack (o );
3131 Py_CLEAR (o -> index );
3232 Py_CLEAR (o -> names );
33+ Py_CLEAR (o -> get_dataclass_fields_func );
3334 PyMem_RawFree (o -> descs );
3435 PyObject_GC_Del (o );
3536}
@@ -177,12 +178,24 @@ record_desc_dir(EdgeRecordDescObject *o, PyObject *args)
177178}
178179
179180
181+ static PyObject *
182+ record_set_dataclass_fields_func (EdgeRecordDescObject * o , PyObject * arg )
183+ {
184+ Py_CLEAR (o -> get_dataclass_fields_func );
185+ o -> get_dataclass_fields_func = arg ;
186+ Py_INCREF (arg );
187+ Py_RETURN_NONE ;
188+ }
189+
190+
180191static PyMethodDef record_desc_methods [] = {
181192 {"is_linkprop" , (PyCFunction )record_desc_is_linkprop , METH_O , NULL },
182193 {"is_link" , (PyCFunction )record_desc_is_link , METH_O , NULL },
183194 {"is_implicit" , (PyCFunction )record_desc_is_implicit , METH_O , NULL },
184195 {"get_pos" , (PyCFunction )record_desc_get_pos , METH_O , NULL },
185196 {"__dir__" , (PyCFunction )record_desc_dir , METH_NOARGS , NULL },
197+ {"set_dataclass_fields_func" ,
198+ (PyCFunction )record_set_dataclass_fields_func , METH_O , NULL },
186199 {NULL , NULL }
187200};
188201
@@ -349,6 +362,7 @@ EdgeRecordDesc_New(PyObject *names, PyObject *flags, PyObject *cards)
349362
350363 o -> size = size ;
351364 o -> idpos = idpos ;
365+ o -> get_dataclass_fields_func = NULL ;
352366
353367 PyObject_GC_Track (o );
354368 return (PyObject * )o ;
@@ -537,6 +551,25 @@ EdgeRecordDesc_List(PyObject *ob, uint8_t include_mask, uint8_t exclude_mask)
537551}
538552
539553
554+ PyObject *
555+ EdgeRecordDesc_GetDataclassFields (PyObject * ob )
556+ {
557+ if (!EdgeRecordDesc_Check (ob )) {
558+ PyErr_BadInternalCall ();
559+ return NULL ;
560+ }
561+
562+ EdgeRecordDescObject * o = (EdgeRecordDescObject * )ob ;
563+
564+ // bpo-37194 added PyObject_CallNoArgs() to Python 3.9.0a1
565+ #if PY_VERSION_HEX < 0x030900A1
566+ return PyObject_CallFunctionObjArgs (o -> get_dataclass_fields_func , NULL );
567+ #else
568+ return PyObject_CallNoArgs (o -> get_dataclass_fields_func );
569+ #endif
570+ }
571+
572+
540573PyObject *
541574EdgeRecordDesc_InitType (void )
542575{
0 commit comments