diff --git a/Lib/test/test_metaclass.py b/Lib/test/test_metaclass.py --- a/Lib/test/test_metaclass.py +++ b/Lib/test/test_metaclass.py @@ -180,7 +180,7 @@ meta: C () ns: [('__module__', 'test.test_metaclass'), ('__qualname__', 'C'), ('a', 42), ('b', 24)] kw: [] - >>> type(C) is dict + >>> type(C) is OrderedDict True >>> print(sorted(C.items())) [('__module__', 'test.test_metaclass'), ('__qualname__', 'C'), ('a', 42), ('b', 24)] @@ -212,7 +212,7 @@ The default metaclass must define a __prepare__() method. >>> type.__prepare__() - {} + OrderedDict() >>> Make sure it works with subclassing. @@ -248,6 +248,7 @@ """ +from collections import OrderedDict import sys # Trace function introduces __locals__ which causes various tests to fail. diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2310,6 +2310,7 @@ } } + /* XXX Does PyDict_Type have to be exact? */ /* Check arguments: (name, bases, dict) */ if (!PyArg_ParseTupleAndKeywords(args, kwds, "UO!O!:type", kwlist, &name, @@ -2352,6 +2353,8 @@ goto error; } + /* Copy the definition namespace into a new dict. */ + /* XXX Is OrderedDict compatible with the split-keys mechanism? */ dict = PyDict_Copy(orig_dict); if (dict == NULL) goto error; @@ -3085,7 +3088,7 @@ static PyObject * type_prepare(PyObject *self, PyObject *args, PyObject *kwds) { - return PyDict_New(); + return PyODict_New(); } /* diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -145,7 +145,7 @@ if (prep == NULL) { if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); - ns = PyDict_New(); + ns = PyODict_New(); } else { Py_DECREF(meta);