@@ -85,10 +85,10 @@ get_default_action(void)
8585
8686 default_action = get_warnings_attr ("defaultaction" );
8787 if (default_action == NULL ) {
88- if (PyErr_Occurred ()) {
89- return NULL ;
90- }
91- return _default_action ;
88+ if (PyErr_Occurred ()) {
89+ return NULL ;
90+ }
91+ return _default_action ;
9292 }
9393
9494 Py_DECREF (_default_action );
@@ -202,12 +202,12 @@ normalize_module(PyObject *filename)
202202
203203 mod_str = PyString_AsString (filename );
204204 if (mod_str == NULL )
205- return NULL ;
205+ return NULL ;
206206 len = PyString_Size (filename );
207207 if (len < 0 )
208208 return NULL ;
209209 if (len >= 3 &&
210- strncmp (mod_str + (len - 3 ), ".py" , 3 ) == 0 ) {
210+ strncmp (mod_str + (len - 3 ), ".py" , 3 ) == 0 ) {
211211 module = PyString_FromStringAndSize (mod_str , len - 3 );
212212 }
213213 else {
@@ -251,7 +251,7 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
251251
252252 name = PyObject_GetAttrString (category , "__name__" );
253253 if (name == NULL ) /* XXX Can an object lack a '__name__' attribute? */
254- return ;
254+ return ;
255255
256256 f_stderr = PySys_GetObject ("stderr" );
257257 if (f_stderr == NULL ) {
@@ -341,7 +341,7 @@ warn_explicit(PyObject *category, PyObject *message,
341341 rc = already_warned (registry , key , 0 );
342342 if (rc == -1 )
343343 goto cleanup ;
344- else if (rc == 1 )
344+ else if (rc == 1 )
345345 goto return_none ;
346346 /* Else this warning hasn't been generated before. */
347347 }
@@ -492,9 +492,9 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
492492 /* Setup filename. */
493493 * filename = PyDict_GetItemString (globals , "__file__" );
494494 if (* filename != NULL ) {
495- Py_ssize_t len = PyString_Size (* filename );
495+ Py_ssize_t len = PyString_Size (* filename );
496496 const char * file_str = PyString_AsString (* filename );
497- if (file_str == NULL || (len < 0 && PyErr_Occurred ()))
497+ if (file_str == NULL || (len < 0 && PyErr_Occurred ()))
498498 goto handle_error ;
499499
500500 /* if filename.lower().endswith((".pyc", ".pyo")): */
@@ -506,10 +506,10 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
506506 tolower (file_str [len - 1 ]) == 'o' ))
507507 {
508508 * filename = PyString_FromStringAndSize (file_str , len - 1 );
509- if (* filename == NULL )
510- goto handle_error ;
511- }
512- else
509+ if (* filename == NULL )
510+ goto handle_error ;
511+ }
512+ else
513513 Py_INCREF (* filename );
514514 }
515515 else {
@@ -536,8 +536,8 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
536536 else {
537537 /* embedded interpreters don't have sys.argv, see bug #839151 */
538538 * filename = PyString_FromString ("__main__" );
539- if (* filename == NULL )
540- goto handle_error ;
539+ if (* filename == NULL )
540+ goto handle_error ;
541541 }
542542 }
543543 if (* filename == NULL ) {
@@ -839,26 +839,29 @@ create_filter(PyObject *category, const char *action)
839839static PyObject *
840840init_filters (void )
841841{
842- PyObject * filters = PyList_New (3 );
842+ PyObject * filters = PyList_New (4 );
843843 const char * bytes_action ;
844844 if (filters == NULL )
845845 return NULL ;
846846
847847 PyList_SET_ITEM (filters , 0 ,
848+ create_filter (PyExc_DeprecationWarning , "ignore" ));
849+ PyList_SET_ITEM (filters , 1 ,
848850 create_filter (PyExc_PendingDeprecationWarning , "ignore" ));
849- PyList_SET_ITEM (filters , 1 , create_filter (PyExc_ImportWarning , "ignore" ));
851+ PyList_SET_ITEM (filters , 2 , create_filter (PyExc_ImportWarning , "ignore" ));
850852 if (Py_BytesWarningFlag > 1 )
851853 bytes_action = "error" ;
852854 else if (Py_BytesWarningFlag )
853855 bytes_action = "default" ;
854856 else
855857 bytes_action = "ignore" ;
856- PyList_SET_ITEM (filters , 2 , create_filter (PyExc_BytesWarning ,
858+ PyList_SET_ITEM (filters , 3 , create_filter (PyExc_BytesWarning ,
857859 bytes_action ));
858860
859861 if (PyList_GET_ITEM (filters , 0 ) == NULL ||
860862 PyList_GET_ITEM (filters , 1 ) == NULL ||
861- PyList_GET_ITEM (filters , 2 ) == NULL ) {
863+ PyList_GET_ITEM (filters , 2 ) == NULL ||
864+ PyList_GET_ITEM (filters , 3 ) == NULL ) {
862865 Py_DECREF (filters );
863866 return NULL ;
864867 }
0 commit comments