bpo-46891: Fix creating a new instance of a module subclass with slots (GH-31643)

This commit is contained in:
Mark Shannon 2022-03-03 10:38:27 +00:00 committed by GitHub
parent 3c4abfab0d
commit 751c9ed801
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View file

@ -4,6 +4,7 @@
#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_interp.h" // PyInterpreterState.importlib
#include "pycore_object.h" // _PyType_AllocNoTrack
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_moduleobject.h" // _PyModule_GetDef()
#include "structmember.h" // PyMemberDef
@ -80,7 +81,7 @@ static PyModuleObject *
new_module_notrack(PyTypeObject *mt)
{
PyModuleObject *m;
m = PyObject_GC_New(PyModuleObject, mt);
m = (PyModuleObject *)_PyType_AllocNoTrack(mt, 0);
if (m == NULL)
return NULL;
m->md_def = NULL;