@@ -138,6 +138,7 @@ As a consequence of this, split keys have a maximum size of 16.
138138// Forward declarations
139139static PyObject * frozendict_new (PyTypeObject * type , PyObject * args ,
140140 PyObject * kwds );
141+ static PyObject * dict_new (PyTypeObject * type , PyObject * args , PyObject * kwds );
141142static int dict_merge (PyObject * a , PyObject * b , int override );
142143
143144
@@ -3305,15 +3306,18 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
33053306 return NULL ;
33063307 }
33073308
3308- // If cls is a frozendict subclass with overridden constructor,
3309+ // If cls is a dict or frozendict subclass with overridden constructor,
33093310 // copy the frozendict.
33103311 PyTypeObject * cls_type = _PyType_CAST (cls );
3311- if (PyFrozenDict_Check (d )
3312- && PyObject_IsSubclass (cls , (PyObject * )& PyFrozenDict_Type )
3313- && cls_type -> tp_new != frozendict_new )
3314- {
3312+ if (PyFrozenDict_Check (d ) && cls_type -> tp_new != frozendict_new ) {
33153313 // Subclass-friendly copy
3316- PyObject * copy = frozendict_new (cls_type , NULL , NULL );
3314+ PyObject * copy ;
3315+ if (PyObject_IsSubclass (cls , (PyObject * )& PyFrozenDict_Type )) {
3316+ copy = frozendict_new (cls_type , NULL , NULL );
3317+ }
3318+ else {
3319+ copy = dict_new (cls_type , NULL , NULL );
3320+ }
33173321 if (copy == NULL ) {
33183322 Py_DECREF (d );
33193323 return NULL ;
0 commit comments