Visitar URL original
gh-89546: Clean up PyType_FromMetaclass by encukou · Pull Request #93686 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move offset setting to before PyType_Ready
  • Loading branch information
encukou committed Jun 10, 2022
commit 7fd0c6da67030d56d4bbbb20055bcd342c8e75ac
16 changes: 11 additions & 5 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3635,9 +3635,17 @@ PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module,
type->tp_dealloc = subtype_dealloc;
}

if (vectorcalloffset) {
type->tp_vectorcall_offset = vectorcalloffset;
}
/* Set up offsets */

type->tp_vectorcall_offset = vectorcalloffset;
type->tp_weaklistoffset = weaklistoffset;
type->tp_dictoffset = dictoffset;

/* Ready the type (which includes inheritance).
*
* After this call we should generally only touch up what's
* accessible to Python code, like __dict__.
*/

if (PyType_Ready(type) < 0) {
goto finally;
Expand All @@ -3660,13 +3668,11 @@ PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module,
}

if (weaklistoffset) {
type->tp_weaklistoffset = weaklistoffset;
if (PyDict_DelItemString((PyObject *)type->tp_dict, "__weaklistoffset__") < 0) {
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
goto finally;
}
}
if (dictoffset) {
type->tp_dictoffset = dictoffset;
if (PyDict_DelItemString((PyObject *)type->tp_dict, "__dictoffset__") < 0) {
goto finally;
}
Expand Down