File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -488,15 +488,22 @@ int
488488PyModule_AddObject (PyObject * m , char * name , PyObject * o )
489489{
490490 PyObject * dict ;
491- if (!PyModule_Check (m ) || o == NULL )
492- return -1 ;
491+ if (!PyModule_Check (m ) || o == NULL ) {
492+ PyErr_SetString (PyExc_TypeError ,
493+ "PyModule_AddObject() needs module as first arg" );
494+ return -1 ;
495+ }
493496 dict = PyModule_GetDict (m );
494- if (dict == NULL )
497+ if (dict == NULL ) {
498+ /* Internal error -- modules must have a dict! */
499+ PyErr_Format (PyExc_SystemError , "module '%s' has no __dict__" ,
500+ PyModule_GetName (m ));
501+ return -1 ;
502+ }
503+ if (PyDict_SetItemString (dict , name , o ))
495504 return -1 ;
496- if (PyDict_SetItemString (dict , name , o ))
497- return -1 ;
498- Py_DECREF (o );
499- return 0 ;
505+ Py_DECREF (o );
506+ return 0 ;
500507}
501508
502509int
You can’t perform that action at this time.
0 commit comments