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

Unified Diff: Python/_warnings.c

Issue 4180: warnings.simplefilter("always") does not make warnings always show up
Patch Set: Created 11 years, 4 months ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_warnings.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Python/_warnings.c
===================================================================
--- Python/_warnings.c (revision 66997)
+++ Python/_warnings.c (working copy)
@@ -603,14 +603,33 @@
static PyObject *
do_warn(PyObject *message, PyObject *category, Py_ssize_t stack_level)
{
- PyObject *filename, *module, *registry, *res;
+ PyObject *filename, *module, *registry, *res, *func;
int lineno;
if (!setup_context(stack_level, &filename, &lineno, &module, &registry))
return NULL;
- res = warn_explicit(category, message, filename, lineno, module, registry,
- NULL);
+ func = get_warnings_attr("warn_explicit");
+ if (func == NULL) {
+ if (PyErr_Occurred())
+ return NULL;
+ res = warn_explicit(category, message, filename, lineno, module, registry,
+ NULL);
+ }
+ else {
+ PyObject *lineno_obj;
+ lineno_obj = PyInt_FromLong(lineno);
+ if (lineno_obj == NULL) {
+ Py_DECREF(filename);
+ Py_DECREF(registry);
+ Py_DECREF(module);
+ return NULL;
+ }
+ res = PyObject_CallFunctionObjArgs(func, message, category, filename, lineno_obj,
+ module, registry, NULL);
+ Py_DECREF(lineno_obj);
+ Py_DECREF(func);
+ }
Py_DECREF(filename);
Py_DECREF(registry);
Py_DECREF(module);
« 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+