Better error message

This commit is contained in:
Jeremy Hylton 2003-06-21 21:35:25 +00:00
parent ac8657bb0e
commit c44dbc46fe
1 changed files with 7 additions and 1 deletions

View File

@ -514,11 +514,17 @@ int
PyModule_AddObject(PyObject *m, char *name, PyObject *o) PyModule_AddObject(PyObject *m, char *name, PyObject *o)
{ {
PyObject *dict; PyObject *dict;
if (!PyModule_Check(m) || o == NULL) { if (!PyModule_Check(m)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"PyModule_AddObject() needs module as first arg"); "PyModule_AddObject() needs module as first arg");
return -1; return -1;
} }
if (!o) {
PyErr_SetString(PyExc_TypeError,
"PyModule_AddObject() needs non-NULL value");
return -1;
}
dict = PyModule_GetDict(m); dict = PyModule_GetDict(m);
if (dict == NULL) { if (dict == NULL) {
/* Internal error -- modules must have a dict! */ /* Internal error -- modules must have a dict! */