[Python-checkins] python/dist/src/Python modsupport.c,2.59,2.60

fdrake@users.sourceforge.net fdrake@users.sourceforge.net
Mon, 17 Jun 2002 10:17:00 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv26470/Python

Modified Files:
	modsupport.c 
Log Message:
PyModule_AddObject():  Added missing exceptions.
Closes SF bug #523473.


Index: modsupport.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v
retrieving revision 2.59
retrieving revision 2.60
diff -C2 -d -r2.59 -r2.60
*** modsupport.c	28 Mar 2002 05:33:33 -0000	2.59
--- modsupport.c	17 Jun 2002 17:16:57 -0000	2.60
***************
*** 489,501 ****
  {
  	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;
  }
  
--- 489,508 ----
  {
  	PyObject *dict;
! 	if (!PyModule_Check(m) || o == NULL) {
! 		PyErr_SetString(PyExc_TypeError,
! 			    "PyModule_AddObject() needs module as first arg");
! 		return -1;
! 	}
  	dict = PyModule_GetDict(m);
! 	if (dict == NULL) {
! 		/* Internal error -- modules must have a dict! */
! 		PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
! 			     PyModule_GetName(m));
  		return -1;
! 	}
! 	if (PyDict_SetItemString(dict, name, o))
! 		return -1;
! 	Py_DECREF(o);
! 	return 0;
  }