File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -467,15 +467,22 @@ int
467
467
PyModule_AddObject (PyObject * m , char * name , PyObject * o )
468
468
{
469
469
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
+ }
472
475
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 ))
474
483
return -1 ;
475
- if (PyDict_SetItemString (dict , name , o ))
476
- return -1 ;
477
- Py_DECREF (o );
478
- return 0 ;
484
+ Py_DECREF (o );
485
+ return 0 ;
479
486
}
480
487
481
488
int
You can’t perform that action at this time.
0 commit comments