File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -588,3 +588,37 @@ PyErr_WriteUnraisable(PyObject *obj)
588588 Py_XDECREF (v );
589589 Py_XDECREF (tb );
590590}
591+
592+
593+ /* Function to issue a warning message; may raise an exception. */
594+ int
595+ PyErr_Warn (PyObject * category , char * message )
596+ {
597+ PyObject * mod , * dict , * func = NULL ;
598+
599+ mod = PyImport_ImportModule ("warnings" );
600+ if (mod != NULL ) {
601+ dict = PyModule_GetDict (mod );
602+ func = PyDict_GetItemString (dict , "warn" );
603+ Py_DECREF (mod );
604+ }
605+ if (func == NULL ) {
606+ PySys_WriteStderr ("warning: %s\n" , message );
607+ return 0 ;
608+ }
609+ else {
610+ PyObject * args , * res ;
611+
612+ if (category == NULL )
613+ category = PyExc_RuntimeWarning ;
614+ args = Py_BuildValue ("(sO)" , message , category );
615+ if (args == NULL )
616+ return -1 ;
617+ res = PyEval_CallObject (func , args );
618+ Py_DECREF (args );
619+ if (res == NULL )
620+ return -1 ;
621+ Py_DECREF (res );
622+ return 0 ;
623+ }
624+ }
You can’t perform that action at this time.
0 commit comments