Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit78c4095

Browse files
committed
PyModule_AddObject(): Added missing exceptions.
Closes SF bug #523473.
1 parentf89e4dd commit78c4095

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

‎Python/modsupport.c‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,15 +467,22 @@ int
467467
PyModule_AddObject(PyObject*m,char*name,PyObject*o)
468468
{
469469
PyObject*dict;
470-
if (!PyModule_Check(m)||o==NULL)
471-
return-1;
470+
if (!PyModule_Check(m)||o==NULL) {
471+
PyErr_SetString(PyExc_TypeError,
472+
"PyModule_AddObject() needs module as first arg");
473+
return-1;
474+
}
472475
dict=PyModule_GetDict(m);
473-
if (dict==NULL)
476+
if (dict==NULL) {
477+
/* Internal error -- modules must have a dict! */
478+
PyErr_Format(PyExc_SystemError,"module '%s' has no __dict__",
479+
PyModule_GetName(m));
480+
return-1;
481+
}
482+
if (PyDict_SetItemString(dict,name,o))
474483
return-1;
475-
if (PyDict_SetItemString(dict,name,o))
476-
return-1;
477-
Py_DECREF(o);
478-
return0;
484+
Py_DECREF(o);
485+
return0;
479486
}
480487

481488
int

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp