@@ -179,6 +179,26 @@ managed_static_type_init_def(static_type_def def, PyTypeObject *type)
179
179
"tp" slots, but it's simpler to copy the whole struct. */
180
180
PyTypeObject * deftype = & def -> type ;
181
181
memcpy (deftype , type , sizeof (PyTypeObject ));
182
+ if (deftype -> tp_as_buffer != NULL ) {
183
+ memcpy (& def -> as_buffer , type -> tp_as_buffer , sizeof (PyBufferProcs ));
184
+ deftype -> tp_as_buffer = & def -> as_buffer ;
185
+ }
186
+ if (deftype -> tp_as_sequence != NULL ) {
187
+ memcpy (& def -> as_sequence , type -> tp_as_sequence , sizeof (PySequenceMethods ));
188
+ deftype -> tp_as_sequence = & def -> as_sequence ;
189
+ }
190
+ if (deftype -> tp_as_mapping != NULL ) {
191
+ memcpy (& def -> as_mapping , type -> tp_as_mapping , sizeof (PyMappingMethods ));
192
+ deftype -> tp_as_mapping = & def -> as_mapping ;
193
+ }
194
+ if (deftype -> tp_as_number != NULL ) {
195
+ memcpy (& def -> as_number , type -> tp_as_number , sizeof (PyNumberMethods ));
196
+ deftype -> tp_as_number = & def -> as_number ;
197
+ }
198
+ if (deftype -> tp_as_async != NULL ) {
199
+ memcpy (& def -> as_async , type -> tp_as_async , sizeof (PyAsyncMethods ));
200
+ deftype -> tp_as_async = & def -> as_async ;
201
+ }
182
202
}
183
203
184
204
static void
@@ -213,6 +233,21 @@ managed_static_type_fini_def(static_type_def def, PyTypeObject *type,
213
233
void * * typeptr = slotptr (type , p -> offset );
214
234
* typeptr = * defptr ;
215
235
}
236
+ if (deftype -> tp_as_buffer == NULL ) {
237
+ type -> tp_as_buffer = NULL ;
238
+ }
239
+ if (deftype -> tp_as_sequence == NULL ) {
240
+ type -> tp_as_sequence = NULL ;
241
+ }
242
+ if (deftype -> tp_as_mapping == NULL ) {
243
+ type -> tp_as_mapping = NULL ;
244
+ }
245
+ if (deftype -> tp_as_number == NULL ) {
246
+ type -> tp_as_number = NULL ;
247
+ }
248
+ if (deftype -> tp_as_async == NULL ) {
249
+ type -> tp_as_async = NULL ;
250
+ }
216
251
217
252
/* Currently, there is a small set of cases where a static type
218
253
might be used after it has been finalized. For example, some
0 commit comments