[Numpy-discussion] un-silencing Numpy's deprecation warnings

Peter numpy-discussion at maubp.freeserve.co.uk
Tue May 22 05:50:38 EDT 2012

On Tue, May 22, 2012 at 9:27 AM, Nathaniel Smith <njs at pobox.com> wrote:
> So starting in Python 2.7 and 3.2, the Python developers have made
> DeprecationWarnings invisible by default:
>  http://docs.python.org/whatsnew/2.7.html#the-future-for-python-2-x
>  http://mail.python.org/pipermail/stdlib-sig/2009-November/000789.html
>  http://bugs.python.org/issue7319
> The only way to see them is to explicitly request them by running
> Python with -Wd.
> The logic seems to be that between the end-of-development for 2.7 and
> the moratorium on 3.2 changes, there were a *lot* of added
> deprecations that were annoying people, and deprecations in the Python
> stdlib mean "this code is probably sub-optimal but it will still
> continue to work indefinitely". So they consider that deprecation
> warnings are like a lint tool for conscientious developers who
> remember to test their code with -Wd, but not something to bother
> users with.
> In Numpy, the majority of our users are actually (relatively
> unsophisticated) developers, and we don't plan to support deprecated
> features indefinitely. Our deprecations seem to better match what
> Python calls a "FutureWarning": "warnings about constructs that will
> change semantically in the future."
>  http://docs.python.org/library/warnings.html#warning-categories
> FutureWarning is displayed by default, and available in all versions of Python.
> So maybe we should change all our DeprecationWarnings into
> FutureWarnings (or at least the ones that we actually plan to follow
> through on). Thoughts?
> - N

We had the same discussion for Biopython two years ago, and
introduced our own warning class to avoid our deprecations being
silent (and thus almost pointless). It is just a subclass of Warning
(originally we used a subclass of UserWarning).

More information about the NumPy-Discussion mailing list