Add PyDict_Copy() function to C API for dicts. It returns a new

dictionary that contains the same key/value pairs as p.
This commit is contained in:
Jeremy Hylton 2000-03-30 22:27:31 +00:00
parent c06653f567
commit a12c7a7620
4 changed files with 25 additions and 2 deletions

View file

@ -738,11 +738,25 @@ dict_copy(mp, args)
register dictobject *mp;
PyObject *args;
{
if (!PyArg_Parse(args, ""))
return NULL;
return PyDict_Copy((PyObject*)mp);
}
PyObject *
PyDict_Copy(o)
PyObject *o;
{
register dictobject *mp;
register int i;
dictobject *copy;
dictentry *entry;
if (!PyArg_Parse(args, ""))
if (o == NULL || !PyDict_Check(o)) {
PyErr_BadInternalCall();
return NULL;
}
mp = (dictobject *)o;
copy = (dictobject *)PyDict_New();
if (copy == NULL)
return NULL;