|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * The Universal Permissive License (UPL), Version 1.0
|
@@ -306,29 +306,31 @@ static void inherit_slots(PyTypeObject *type, PyTypeObject *base) {
|
306 | 306 | COPYSLOT(tp_iter);
|
307 | 307 | COPYSLOT(tp_iternext);
|
308 | 308 | }
|
309 |
| - |
310 |
| - if ((PyTypeObject_tp_flags(type) & Py_TPFLAGS_HAVE_FINALIZE) && |
311 |
| - (PyTypeObject_tp_flags(base) & Py_TPFLAGS_HAVE_FINALIZE)) { |
312 |
| - COPYSLOT(tp_finalize); |
313 |
| - } |
314 |
| - if ((PyTypeObject_tp_flags(type) & Py_TPFLAGS_HAVE_GC) == |
315 |
| - (PyTypeObject_tp_flags(base) & Py_TPFLAGS_HAVE_GC)) { |
316 |
| - /* They agree about gc. */ |
317 |
| - COPYSLOT(tp_free); |
318 |
| - } |
319 |
| - else if ((PyTypeObject_tp_flags(type) & Py_TPFLAGS_HAVE_GC) && |
320 |
| - PyTypeObject_tp_free(type) == NULL && |
321 |
| - PyTypeObject_tp_free(base) == PyObject_Free) { |
322 |
| - /* A bit of magic to plug in the correct default |
323 |
| - * tp_free function when a derived class adds gc, |
324 |
| - * didn't define tp_free, and the base uses the |
325 |
| - * default non-gc tp_free. |
| 309 | + { |
| 310 | + COPYSLOT(tp_alloc); |
| 311 | + if ((PyTypeObject_tp_flags(type) & Py_TPFLAGS_HAVE_FINALIZE) && |
| 312 | + (PyTypeObject_tp_flags(base) & Py_TPFLAGS_HAVE_FINALIZE)) { |
| 313 | + COPYSLOT(tp_finalize); |
| 314 | + } |
| 315 | + if ((PyTypeObject_tp_flags(type) & Py_TPFLAGS_HAVE_GC) == |
| 316 | + (PyTypeObject_tp_flags(base) & Py_TPFLAGS_HAVE_GC)) { |
| 317 | + /* They agree about gc. */ |
| 318 | + COPYSLOT(tp_free); |
| 319 | + } |
| 320 | + else if ((PyTypeObject_tp_flags(type) & Py_TPFLAGS_HAVE_GC) && |
| 321 | + PyTypeObject_tp_free(type) == NULL && |
| 322 | + PyTypeObject_tp_free(base) == PyObject_Free) { |
| 323 | + /* A bit of magic to plug in the correct default |
| 324 | + * tp_free function when a derived class adds gc, |
| 325 | + * didn't define tp_free, and the base uses the |
| 326 | + * default non-gc tp_free. |
| 327 | + */ |
| 328 | + set_PyTypeObject_tp_free(type, PyObject_GC_Del); |
| 329 | + } |
| 330 | + /* else they didn't agree about gc, and there isn't something |
| 331 | + * obvious to be done -- the type is on its own. |
326 | 332 | */
|
327 |
| - set_PyTypeObject_tp_free(type, PyObject_GC_Del); |
328 | 333 | }
|
329 |
| - /* else they didn't agree about gc, and there isn't something |
330 |
| - * obvious to be done -- the type is on its own. |
331 |
| - */ |
332 | 334 | }
|
333 | 335 |
|
334 | 336 | static int add_member(PyTypeObject* cls, PyObject* type_dict, const char* mname, int mtype, Py_ssize_t moffset, int mflags, char* mdoc) {
|
|
0 commit comments