summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-04-25 22:33:36 +0000
committerBrett Cannon <bcannon@gmail.com>2010-04-25 22:33:36 +0000
commitbdcfa54527554b64eb314fa81e0f529f576cf2f4 (patch)
tree4b91a24a9628d93546129de81f413ae970fa6a27 /Python
parent28ee78ab08d64fdf47b508c7b4b9a1f280b6a1b7 (diff)
downloadcpython-bdcfa54527554b64eb314fa81e0f529f576cf2f4.tar.gz
When DeprecationWarning was silenced by default, it also silenced any use of -Q
by default as well. This change fixes that by treating -Q like -3 when it comes to DeprecationWarning; using it causes the silencing to not occur. Fixes issue #7319.
Diffstat (limited to 'Python')
-rw-r--r--Python/_warnings.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index bddd44cec6..1dc2512851 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -280,7 +280,7 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
PyFile_WriteString("\n", f_stderr);
}
else
- _Py_DisplaySourceLine(f_stderr, PyString_AS_STRING(filename),
+ _Py_DisplaySourceLine(f_stderr, PyString_AS_STRING(filename),
lineno, 2);
PyErr_Clear();
}
@@ -294,7 +294,7 @@ warn_explicit(PyObject *category, PyObject *message,
PyObject *item = Py_None;
const char *action;
int rc;
-
+
if (registry && !PyDict_Check(registry) && (registry != Py_None)) {
PyErr_SetString(PyExc_TypeError, "'registry' must be a dict");
return NULL;
@@ -839,8 +839,9 @@ create_filter(PyObject *category, const char *action)
static PyObject *
init_filters(void)
{
- /* Don't silence DeprecationWarning if -3 was used. */
- PyObject *filters = PyList_New(Py_Py3kWarningFlag ? 3 : 4);
+ /* Don't silence DeprecationWarning if -3 or -Q were used. */
+ PyObject *filters = PyList_New(Py_Py3kWarningFlag ||
+ Py_DivisionWarningFlag ? 3 : 4);
unsigned int pos = 0; /* Post-incremented in each use. */
unsigned int x;
const char *bytes_action;
@@ -848,7 +849,8 @@ init_filters(void)
if (filters == NULL)
return NULL;
- if (!Py_Py3kWarningFlag) {
+ /* If guard changes, make sure to update 'filters' initialization above. */
+ if (!Py_Py3kWarningFlag && !Py_DivisionWarningFlag) {
PyList_SET_ITEM(filters, pos++,
create_filter(PyExc_DeprecationWarning, "ignore"));
}