@@ -636,77 +636,6 @@ static PyMemberDef func_memberlist[] = {
636
636
{NULL } /* Sentinel */
637
637
};
638
638
639
- static PyObject *
640
- func_get_name (PyObject * self , void * Py_UNUSED (ignored ))
641
- {
642
- PyFunctionObject * op = _PyFunction_CAST (self );
643
- return Py_NewRef (op -> func_name );
644
- }
645
-
646
- static int
647
- func_set_name (PyObject * self , PyObject * value , void * Py_UNUSED (ignored ))
648
- {
649
- PyFunctionObject * op = _PyFunction_CAST (self );
650
- /* Not legal to del f.func_name or to set it to anything
651
- * other than a string object. */
652
- if (value == NULL || !PyUnicode_Check (value )) {
653
- PyErr_SetString (PyExc_TypeError ,
654
- "__name__ must be set to a string object" );
655
- return -1 ;
656
- }
657
- Py_XSETREF (op -> func_name , Py_NewRef (value ));
658
- return 0 ;
659
- }
660
-
661
- static PyObject *
662
- func_get_qualname (PyObject * self , void * Py_UNUSED (ignored ))
663
- {
664
- PyFunctionObject * op = _PyFunction_CAST (self );
665
- return Py_NewRef (op -> func_qualname );
666
- }
667
-
668
- static int
669
- func_set_qualname (PyObject * self , PyObject * value , void * Py_UNUSED (ignored ))
670
- {
671
- PyFunctionObject * op = _PyFunction_CAST (self );
672
- /* Not legal to del f.__qualname__ or to set it to anything
673
- * other than a string object. */
674
- if (value == NULL || !PyUnicode_Check (value )) {
675
- PyErr_SetString (PyExc_TypeError ,
676
- "__qualname__ must be set to a string object" );
677
- return -1 ;
678
- }
679
- Py_XSETREF (op -> func_qualname , Py_NewRef (value ));
680
- return 0 ;
681
- }
682
-
683
- static PyObject *
684
- func_get_type_params (PyObject * self , void * Py_UNUSED (ignored ))
685
- {
686
- PyFunctionObject * op = _PyFunction_CAST (self );
687
- if (op -> func_typeparams == NULL ) {
688
- return PyTuple_New (0 );
689
- }
690
-
691
- assert (PyTuple_Check (op -> func_typeparams ));
692
- return Py_NewRef (op -> func_typeparams );
693
- }
694
-
695
- static int
696
- func_set_type_params (PyObject * self , PyObject * value , void * Py_UNUSED (ignored ))
697
- {
698
- /* Not legal to del f.__type_params__ or to set it to anything
699
- * other than a tuple object. */
700
- PyFunctionObject * op = _PyFunction_CAST (self );
701
- if (value == NULL || !PyTuple_Check (value )) {
702
- PyErr_SetString (PyExc_TypeError ,
703
- "__type_params__ must be set to a tuple" );
704
- return -1 ;
705
- }
706
- Py_XSETREF (op -> func_typeparams , Py_NewRef (value ));
707
- return 0 ;
708
- }
709
-
710
639
PyObject *
711
640
_Py_set_function_type_params (PyThreadState * Py_UNUSED (ignored ), PyObject * func ,
712
641
PyObject * type_params )
@@ -1116,16 +1045,129 @@ function___annotate___set_impl(PyFunctionObject *self, PyObject *value)
1116
1045
}
1117
1046
}
1118
1047
1048
+ /*[clinic input]
1049
+ @critical_section
1050
+ @getter
1051
+ function.__name__
1052
+
1053
+ Get the function name.
1054
+ [clinic start generated code]*/
1055
+
1056
+ static PyObject *
1057
+ function___name___get_impl (PyFunctionObject * self )
1058
+ /*[clinic end generated code: output=436852c5b4f6d259 input=64ef3b4545423cdc]*/
1059
+ {
1060
+ return Py_NewRef (self -> func_name );
1061
+ }
1062
+
1063
+ /*[clinic input]
1064
+ @critical_section
1065
+ @setter
1066
+ function.__name__
1067
+ [clinic start generated code]*/
1068
+
1069
+ static int
1070
+ function___name___set_impl (PyFunctionObject * self , PyObject * value )
1071
+ /*[clinic end generated code: output=2c571635b003b9cc input=705634aafaa00198]*/
1072
+ {
1073
+ /* Not legal to del f.func_name or to set it to anything
1074
+ * other than a string object. */
1075
+ if (value == NULL || !PyUnicode_Check (value )) {
1076
+ PyErr_SetString (PyExc_TypeError ,
1077
+ "__name__ must be set to a string object" );
1078
+ return -1 ;
1079
+ }
1080
+ Py_XSETREF (self -> func_name , Py_NewRef (value ));
1081
+ return 0 ;
1082
+ }
1083
+
1084
+ /*[clinic input]
1085
+ @critical_section
1086
+ @getter
1087
+ function.__qualname__
1088
+
1089
+ Get the qualified name for a function.
1090
+ [clinic start generated code]*/
1091
+
1092
+ static PyObject *
1093
+ function___qualname___get_impl (PyFunctionObject * self )
1094
+ /*[clinic end generated code: output=8fbd60e64464da5f input=d6dab58778741083]*/
1095
+ {
1096
+ return Py_NewRef (self -> func_qualname );
1097
+ }
1098
+
1099
+ /*[clinic input]
1100
+ @critical_section
1101
+ @setter
1102
+ function.__qualname__
1103
+ [clinic start generated code]*/
1104
+
1105
+ static int
1106
+ function___qualname___set_impl (PyFunctionObject * self , PyObject * value )
1107
+ /*[clinic end generated code: output=4cc5e270fd55f139 input=c803ac4dfdf04c87]*/
1108
+ {
1109
+ /* Not legal to del f.__qualname__ or to set it to anything
1110
+ * other than a string object. */
1111
+ if (value == NULL || !PyUnicode_Check (value )) {
1112
+ PyErr_SetString (PyExc_TypeError ,
1113
+ "__qualname__ must be set to a string object" );
1114
+ return -1 ;
1115
+ }
1116
+ Py_XSETREF (self -> func_qualname , Py_NewRef (value ));
1117
+ return 0 ;
1118
+ }
1119
+
1120
+ /*[clinic input]
1121
+ @critical_section
1122
+ @getter
1123
+ function.__type_params__
1124
+
1125
+ Get the declared type parameters for a function.
1126
+ [clinic start generated code]*/
1127
+
1128
+ static PyObject *
1129
+ function___type_params___get_impl (PyFunctionObject * self )
1130
+ /*[clinic end generated code: output=eb844d7ffca517a8 input=0864721484293724]*/
1131
+ {
1132
+ if (self -> func_typeparams == NULL ) {
1133
+ return PyTuple_New (0 );
1134
+ }
1135
+
1136
+ assert (PyTuple_Check (self -> func_typeparams ));
1137
+ return Py_NewRef (self -> func_typeparams );
1138
+ }
1139
+
1140
+ /*[clinic input]
1141
+ @critical_section
1142
+ @setter
1143
+ function.__type_params__
1144
+ [clinic start generated code]*/
1145
+
1146
+ static int
1147
+ function___type_params___set_impl (PyFunctionObject * self , PyObject * value )
1148
+ /*[clinic end generated code: output=038b4cda220e56fb input=3862fbd4db2b70e8]*/
1149
+ {
1150
+ /* It's not legal to del f.__type_params__ or to set it to anything
1151
+ * other than a tuple object. */
1152
+ if (value == NULL || !PyTuple_Check (value )) {
1153
+ PyErr_SetString (PyExc_TypeError ,
1154
+ "__type_params__ must be set to a tuple" );
1155
+ return -1 ;
1156
+ }
1157
+ Py_XSETREF (self -> func_typeparams , Py_NewRef (value ));
1158
+ return 0 ;
1159
+ }
1160
+
1119
1161
static PyGetSetDef func_getsetlist [] = {
1120
1162
FUNCTION___CODE___GETSETDEF
1121
1163
FUNCTION___DEFAULTS___GETSETDEF
1122
1164
FUNCTION___KWDEFAULTS___GETSETDEF
1123
1165
FUNCTION___ANNOTATIONS___GETSETDEF
1124
1166
FUNCTION___ANNOTATE___GETSETDEF
1125
1167
{"__dict__" , PyObject_GenericGetDict , PyObject_GenericSetDict },
1126
- { "__name__" , func_get_name , func_set_name },
1127
- { "__qualname__" , func_get_qualname , func_set_qualname },
1128
- { "__type_params__" , func_get_type_params , func_set_type_params },
1168
+ FUNCTION___NAME___GETSETDEF
1169
+ FUNCTION___QUALNAME___GETSETDEF
1170
+ FUNCTION___TYPE_PARAMS___GETSETDEF
1129
1171
{NULL } /* Sentinel */
1130
1172
};
1131
1173
0 commit comments