summaryrefslogtreecommitdiffstats
path: root/Python/_warnings.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-03-22 23:28:08 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-03-22 23:28:08 (GMT)
commite19558af1b6979edf27f7a05a6e47a8b5d113390 (patch)
treef901801a0684eba2f662670a178c43d96918c4db /Python/_warnings.c
parent060f9bb6024580272440f57c612ca34d9beaa169 (diff)
downloadcpython-e19558af1b6979edf27f7a05a6e47a8b5d113390.zip
cpython-e19558af1b6979edf27f7a05a6e47a8b5d113390.tar.gz
cpython-e19558af1b6979edf27f7a05a6e47a8b5d113390.tar.bz2
Add a source parameter to warnings.warn()
Issue #26604: * Add a new optional source parameter to _warnings.warn() and warnings.warn() * Modify asyncore, asyncio and _pyio modules to set the source parameter when logging a ResourceWarning warning
Diffstat (limited to 'Python/_warnings.c')
-rw-r--r--Python/_warnings.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 25299fb..dcac57b 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -787,18 +787,19 @@ do_warn(PyObject *message, PyObject *category, Py_ssize_t stack_level,
static PyObject *
warnings_warn(PyObject *self, PyObject *args, PyObject *kwds)
{
- static char *kw_list[] = { "message", "category", "stacklevel", 0 };
- PyObject *message, *category = NULL;
+ static char *kw_list[] = {"message", "category", "stacklevel",
+ "source", NULL};
+ PyObject *message, *category = NULL, *source = NULL;
Py_ssize_t stack_level = 1;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|On:warn", kw_list,
- &message, &category, &stack_level))
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OnO:warn", kw_list,
+ &message, &category, &stack_level, &source))
return NULL;
category = get_category(message, category);
if (category == NULL)
return NULL;
- return do_warn(message, category, stack_level, NULL);
+ return do_warn(message, category, stack_level, source);
}
static PyObject *