[Python-checkins] CVS: python/dist/src/Python modsupport.c,2.52,2.53

Fred L. Drake python-dev@python.org
Fri, 22 Sep 2000 20:24:30 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv1907/Python

Modified Files:
	modsupport.c 
Log Message:

Andrew Kuchling <akuchlin@mems-exchange.org>:
Add three new convenience functions to the PyModule_*() family:
PyModule_AddObject(), PyModule_AddIntConstant(), PyModule_AddStringConstant().

This closes SourceForge patch #101233.


Index: modsupport.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v
retrieving revision 2.52
retrieving revision 2.53
diff -C2 -r2.52 -r2.53
*** modsupport.c	2000/09/15 12:51:01	2.52
--- modsupport.c	2000/09/23 03:24:27	2.53
***************
*** 460,461 ****
--- 460,488 ----
  	return res;
  }
+ 
+ int
+ PyModule_AddObject(PyObject *m, char *name, PyObject *o)
+ {
+ 	PyObject *dict;
+         if (!PyModule_Check(m) || o == NULL)
+                 return -1;
+ 	dict = PyModule_GetDict(m);
+ 	if (dict == NULL)
+ 		return -1;
+         if (PyDict_SetItemString(dict, name, o))
+                 return -1;
+         Py_DECREF(o);
+         return 0;
+ }
+ 
+ int 
+ PyModule_AddIntConstant(PyObject *m, char *name, long value)
+ {
+ 	return PyModule_AddObject(m, name, PyInt_FromLong(value));
+ }
+ 
+ int 
+ PyModule_AddStringConstant(PyObject *m, char *name, char *value)
+ {
+ 	return PyModule_AddObject(m, name, PyString_FromString(value));
+ }