mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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:
parent
c06653f567
commit
a12c7a7620
4 changed files with 25 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue