Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(5)

Side by Side Diff: Python/_warnings.c

Issue 4180: warnings.simplefilter("always") does not make warnings always show up
Patch Set: Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_warnings.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Python.h" 1 #include "Python.h"
2 #include "code.h" /* For DeprecationWarning about adding 'line'. */ 2 #include "code.h" /* For DeprecationWarning about adding 'line'. */
3 #include "frameobject.h" 3 #include "frameobject.h"
4 4
5 #define MODULE_NAME "_warnings" 5 #define MODULE_NAME "_warnings"
6 #define DEFAULT_ACTION_NAME "default_action" 6 #define DEFAULT_ACTION_NAME "default_action"
7 7
8 PyDoc_STRVAR(warnings__doc__, 8 PyDoc_STRVAR(warnings__doc__,
9 MODULE_NAME " provides basic warning filtering support.\n" 9 MODULE_NAME " provides basic warning filtering support.\n"
10 "It is a helper module to speed up interpreter start-up."); 10 "It is a helper module to speed up interpreter start-up.");
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 "category is not a subclass of Warning"); 596 "category is not a subclass of Warning");
597 return NULL; 597 return NULL;
598 } 598 }
599 599
600 return category; 600 return category;
601 } 601 }
602 602
603 static PyObject * 603 static PyObject *
604 do_warn(PyObject *message, PyObject *category, Py_ssize_t stack_level) 604 do_warn(PyObject *message, PyObject *category, Py_ssize_t stack_level)
605 { 605 {
606 PyObject *filename, *module, *registry, *res; 606 PyObject *filename, *module, *registry, *res, *func;
607 int lineno; 607 int lineno;
608 608
609 if (!setup_context(stack_level, &filename, &lineno, &module, &registry)) 609 if (!setup_context(stack_level, &filename, &lineno, &module, &registry))
610 return NULL; 610 return NULL;
611 611
612 res = warn_explicit(category, message, filename, lineno, module, registry, 612 func = get_warnings_attr("warn_explicit");
613 NULL); 613 if (func == NULL) {
614 if (PyErr_Occurred())
615 return NULL;
616 res = warn_explicit(category, message, filename, lineno, module, registr y,
617 NULL);
618 }
619 else {
620 PyObject *lineno_obj;
621 lineno_obj = PyInt_FromLong(lineno);
622 if (lineno_obj == NULL) {
623 Py_DECREF(filename);
624 Py_DECREF(registry);
625 Py_DECREF(module);
626 return NULL;
627 }
628 res = PyObject_CallFunctionObjArgs(func, message, category, filename, li neno_obj,
629 module, registry, NULL);
630 Py_DECREF(lineno_obj);
631 Py_DECREF(func);
632 }
614 Py_DECREF(filename); 633 Py_DECREF(filename);
615 Py_DECREF(registry); 634 Py_DECREF(registry);
616 Py_DECREF(module); 635 Py_DECREF(module);
617 return res; 636 return res;
618 } 637 }
619 638
620 static PyObject * 639 static PyObject *
621 warnings_warn(PyObject *self, PyObject *args, PyObject *kwds) 640 warnings_warn(PyObject *self, PyObject *args, PyObject *kwds)
622 { 641 {
623 static char *kw_list[] = { "message", "category", "stacklevel", 0 }; 642 static char *kw_list[] = { "message", "category", "stacklevel", 0 };
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 Py_INCREF(_once_registry); 924 Py_INCREF(_once_registry);
906 if (PyModule_AddObject(m, "once_registry", _once_registry) < 0) 925 if (PyModule_AddObject(m, "once_registry", _once_registry) < 0)
907 return; 926 return;
908 927
909 default_action = PyString_InternFromString("default"); 928 default_action = PyString_InternFromString("default");
910 if (default_action == NULL) 929 if (default_action == NULL)
911 return; 930 return;
912 if (PyModule_AddObject(m, DEFAULT_ACTION_NAME, default_action) < 0) 931 if (PyModule_AddObject(m, DEFAULT_ACTION_NAME, default_action) < 0)
913 return; 932 return;
914 } 933 }
OLDNEW
« no previous file with comments | « Lib/test/test_warnings.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+