summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-06-17 17:16:57 (GMT)
committerFred Drake <fdrake@acm.org>2002-06-17 17:16:57 (GMT)
commit8311518a5868acef791d5d04853a6d047d20e8ac (patch)
tree22f058ed91b8413bd655debb79ed5ee984dcd08b /Python
parentb084017c7a27ab37ef6918aaf7e0f665c0dbe2ed (diff)
downloadcpython-8311518a5868acef791d5d04853a6d047d20e8ac.zip
cpython-8311518a5868acef791d5d04853a6d047d20e8ac.tar.gz
cpython-8311518a5868acef791d5d04853a6d047d20e8ac.tar.bz2
PyModule_AddObject(): Added missing exceptions.
Closes SF bug #523473.
Diffstat (limited to 'Python')
-rw-r--r--Python/modsupport.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index f29b27c..f4f8298 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -488,15 +488,22 @@ int
PyModule_AddObject(PyObject *m, char *name, PyObject *o)
{
PyObject *dict;
- if (!PyModule_Check(m) || o == NULL)
- return -1;
+ 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)
+ 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;
- if (PyDict_SetItemString(dict, name, o))
- return -1;
- Py_DECREF(o);
- return 0;
+ Py_DECREF(o);
+ return 0;
}
int