[Python-checkins] python/dist/src/Python modsupport.c,2.58,2.58.16.1

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


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

Modified Files:
      Tag: release22-maint
	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.58
retrieving revision 2.58.16.1
diff -C2 -d -r2.58 -r2.58.16.1
*** modsupport.c	17 Aug 2001 18:39:25 -0000	2.58
--- modsupport.c	17 Jun 2002 17:16:34 -0000	2.58.16.1
***************
*** 482,494 ****
  {
  	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;
  }
  
--- 482,501 ----
  {
  	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;
  }