summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-03-30 22:27:31 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-03-30 22:27:31 (GMT)
commita12c7a762091805db6b6479108951dc2fcb95dde (patch)
tree15d23befe65d284484cb9549b49b8710b99ff225 /Objects
parentc06653f56708084fc50bdad6c6301d9bc49c6af1 (diff)
downloadcpython-a12c7a762091805db6b6479108951dc2fcb95dde.zip
cpython-a12c7a762091805db6b6479108951dc2fcb95dde.tar.gz
cpython-a12c7a762091805db6b6479108951dc2fcb95dde.tar.bz2
Add PyDict_Copy() function to C API for dicts. It returns a new
dictionary that contains the same key/value pairs as p.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index ea32e23..beab457 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -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;