File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -623,6 +623,48 @@ PyErr_Warn(PyObject *category, char *message)
623623 }
624624}
625625
626+
627+ /* Warning with explicit origin */
628+ int
629+ PyErr_WarnExplicit (PyObject * category , char * message ,
630+ char * filename , int lineno ,
631+ char * module , PyObject * registry )
632+ {
633+ PyObject * mod , * dict , * func = NULL ;
634+
635+ mod = PyImport_ImportModule ("warnings" );
636+ if (mod != NULL ) {
637+ dict = PyModule_GetDict (mod );
638+ func = PyDict_GetItemString (dict , "warn_explicit" );
639+ Py_DECREF (mod );
640+ }
641+ if (func == NULL ) {
642+ PySys_WriteStderr ("warning: %s\n" , message );
643+ return 0 ;
644+ }
645+ else {
646+ PyObject * args , * res ;
647+
648+ if (category == NULL )
649+ category = PyExc_RuntimeWarning ;
650+ if (registry == NULL )
651+ registry = Py_None ;
652+ args = Py_BuildValue ("(sOsizO)" , message , category ,
653+ filename , lineno , module , registry );
654+ if (args == NULL )
655+ return -1 ;
656+ res = PyEval_CallObject (func , args );
657+ Py_DECREF (args );
658+ if (res == NULL )
659+ return -1 ;
660+ Py_DECREF (res );
661+ return 0 ;
662+ }
663+ }
664+
665+
666+ /* XXX There's a comment missing here */
667+
626668void
627669PyErr_SyntaxLocation (char * filename , int lineno )
628670{
You can’t perform that action at this time.
0 commit comments