[Python-Dev] Proposal: go back to enabling DeprecationWarning by default

Nick Coghlan ncoghlan at gmail.com
Sun Nov 5 21:05:07 EST 2017


On the 12-weeks-to-3.7-feature-freeze thread, Jose Bueno & I both
mistakenly though the async/await deprecation warnings were missing
from 3.6.

They weren't missing, we'd just both forgotten those warnings were off
by default (7 years after the change to the default settings in 2.7 &
3.2).

So my proposal is simple (and not really new): let's revert back to
the way things were in 2.6 and earlier, with DeprecationWarning being
visible by default, and app devs having to silence it explicitly
during application startup (before they start importing third party
modules) if they don't want their users seeing it when running on the
latest Python version (e.g. this would be suitable for open source
apps that get integrated into Linux distros and use the system Python
there).

This will also restore the previously clear semantic and behavioural
different between PendingDeprecationWarning (hidden by default) and
DeprecationWarning (visible by default).

As part of this though, I'd suggest amending the documentation for
DeprecationWarning [1] to specifically cover how to turn it off
programmatically (`warnings.simplefilter("ignore",
DeprecationWarning)`), at the command line (`python -W
ignore::DeprecationWarning ...`), and via the environment
(`PYTHONWARNINGS=ignore::DeprecationWarning`).

(Structurally, I'd probably put that at the end of the warnings
listing as a short introduction to warnings management, with links out
to the relevant sections of the documentation, and just use
DeprecationWarning as the specific example)

Cheers,
Nick.

[1] https://docs.python.org/3/library/exceptions.html#DeprecationWarning

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list