[Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.50,2.51

Jeremy Hylton python-dev@python.org
Thu, 30 Mar 2000 17:27:33 -0500


Update of /projects/cvsroot/python/dist/src/Objects
In directory goon.cnri.reston.va.us:/home/jhylton/python/src/Objects

Modified Files:
	dictobject.c 
Log Message:
Add PyDict_Copy() function to C API for dicts.  It returns a new
dictionary that contains the same key/value pairs as p.


Index: dictobject.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/dictobject.c,v
retrieving revision 2.50
retrieving revision 2.51
diff -C2 -r2.50 -r2.51
*** dictobject.c	2000/03/13 16:01:29	2.50
--- dictobject.c	2000/03/30 22:27:31	2.51
***************
*** 739,747 ****
        PyObject *args;
  {
  	register int i;
  	dictobject *copy;
          dictentry *entry;
! 	if (!PyArg_Parse(args, ""))
  		return NULL;
  	copy = (dictobject *)PyDict_New();
  	if (copy == NULL)
--- 739,761 ----
        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 (o == NULL || !PyDict_Check(o)) {
! 		PyErr_BadInternalCall();
  		return NULL;
+ 	}
+ 	mp = (dictobject *)o;
  	copy = (dictobject *)PyDict_New();
  	if (copy == NULL)