summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_types.py6
-rw-r--r--Objects/dictobject.c8
2 files changed, 4 insertions, 10 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index 106d0a5..1b6f3ac 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -566,9 +566,9 @@ from UserDict import UserDict
class mydict(dict):
def __new__(cls, *args, **kwargs):
return UserDict(*args, **kwargs)
-try: mydict.fromkeys('a b c'.split())
-except TypeError: pass
-else: raise TestFailed, 'dict.fromkeys() failed to detect non-dict class.'
+ud = mydict.fromkeys('ab')
+if ud != {'a':None, 'b':None} or not isinstance(ud,UserDict):
+ raise TestFailed, 'fromkeys did not instantiate using __new__'
# dict.copy()
d = {1:1, 2:2, 3:3}
if d.copy() != {1:1, 2:2, 3:3}: raise TestFailed, 'dict copy'
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index d3603f0..69adc50 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -979,12 +979,6 @@ dict_fromkeys(PyObject *mp, PyObject *args)
d = PyObject_CallObject(cls, NULL);
if (d == NULL)
return NULL;
- if (!PyDict_Check(d)) {
- Py_DECREF(d);
- PyErr_SetString(PyExc_TypeError,
- "class constructor must return a subclass of dict");
- return NULL;
- }
it = PyObject_GetIter(seq);
if (it == NULL){
@@ -999,7 +993,7 @@ dict_fromkeys(PyObject *mp, PyObject *args)
goto Fail;
break;
}
- status = PyDict_SetItem(d, key, value);
+ status = PyObject_SetItem(d, key, value);
Py_DECREF(key);
if (status < 0)
goto Fail;