mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
parent
b084017c7a
commit
8311518a58
1 changed files with 15 additions and 8 deletions
|
@ -488,11 +488,18 @@ 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) || o == NULL) {
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"PyModule_AddObject() needs module as first arg");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
dict = PyModule_GetDict(m);
|
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;
|
return -1;
|
||||||
|
}
|
||||||
if (PyDict_SetItemString(dict, name, o))
|
if (PyDict_SetItemString(dict, name, o))
|
||||||
return -1;
|
return -1;
|
||||||
Py_DECREF(o);
|
Py_DECREF(o);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue