diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -198,6 +198,8 @@ - Issue #15111: __import__ should propagate ImportError when raised as a side-effect of a module triggered from using fromlist. +- Issue #???: Drop restriction that meta.__prepare__() must return a dict. + Library ------- diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2014,10 +2014,10 @@ } /* Check arguments: (name, bases, dict) */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "UO!O!:type", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "UO!O:type", kwlist, &name, &PyTuple_Type, &bases, - &PyDict_Type, &orig_dict)) + &orig_dict)) return NULL; /* Determine the proper metatype to deal with this: */ @@ -2055,7 +2055,11 @@ goto error; } - dict = PyDict_Copy(orig_dict); + if (PyDict_Check(orig_dict)) + dict = PyDict_Copy(orig_dict); + else + dict = PyObject_CallFunctionObjArgs((PyObject *)&PyDict_Type, + orig_dict, NULL); if (dict == NULL) goto error;