diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-11-20 17:47:03 (GMT) |
---|---|---|
committer | Ćukasz Langa <lukasz@langa.pl> | 2017-11-20 17:47:03 (GMT) |
commit | 895862aa01793a26e74512befb0c66a1da2587d6 (patch) | |
tree | a65de848905ccd0541e15ca5584d69800e264ecf /Python/_warnings.c | |
parent | c5a2071586f735d2a61d1756e7011cfbb6ce86c9 (diff) | |
download | cpython-895862aa01793a26e74512befb0c66a1da2587d6.zip cpython-895862aa01793a26e74512befb0c66a1da2587d6.tar.gz cpython-895862aa01793a26e74512befb0c66a1da2587d6.tar.bz2 |
bpo-32088: Display Deprecation in debug mode (#4474)
When Python is build is debug mode (Py_DEBUG), DeprecationWarning,
PendingDeprecationWarning and ImportWarning warnings are now
displayed by default.
test_venv: run "-m pip" and "-m ensurepip._uninstall" with -W
ignore::DeprecationWarning since pip code is not part of Python.
Diffstat (limited to 'Python/_warnings.c')
-rw-r--r-- | Python/_warnings.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index d0f3941..8cfae76 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -1196,7 +1196,11 @@ create_filter(PyObject *category, const char *action) static PyObject * init_filters(void) { +#ifndef Py_DEBUG PyObject *filters = PyList_New(5); +#else + PyObject *filters = PyList_New(2); +#endif unsigned int pos = 0; /* Post-incremented in each use. */ unsigned int x; const char *bytes_action, *resource_action; @@ -1204,12 +1208,15 @@ init_filters(void) if (filters == NULL) return NULL; +#ifndef Py_DEBUG PyList_SET_ITEM(filters, pos++, create_filter(PyExc_DeprecationWarning, "ignore")); PyList_SET_ITEM(filters, pos++, create_filter(PyExc_PendingDeprecationWarning, "ignore")); PyList_SET_ITEM(filters, pos++, create_filter(PyExc_ImportWarning, "ignore")); +#endif + if (Py_BytesWarningFlag > 1) bytes_action = "error"; else if (Py_BytesWarningFlag) |