8000 In C extensions, use FutureWarning, not DeprecationWarning. by anntzer · Pull Request #15829 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

In C extensions, use FutureWarning, not DeprecationWarning. #15829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2019

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Dec 4, 2019

DeprecationWarnings are hidden by default (that's why
MatplotlibDeprecationWarning inherits from UserWarning, not
DeprecationWarning...) and throwing a MatplotlibDeprecationWarning from
C code is too much of a pain to be worth it; also, CPython suggests
using FutureWarning for this purpose as well.
(https://docs.python.org/3/library/warnings.html#warning-categories)

Release critical so that the warnings actually show up...

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

DeprecationWarnings are hidden by default (that's why
MatplotlibDeprecationWarning inherits from UserWarning, not
DeprecationWarning...) and throwing a MatplotlibDeprecationWarning from
C code is too much of a pain to be worth it; also, CPython suggests
using FutureWarning for this purpose as well.
(https://docs.python.org/3/library/warnings.html#warning-categories)
@anntzer anntzer added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Dec 4, 2019
@anntzer anntzer added this to the v3.2.0 milestone Dec 4, 2019
anntzer referenced this pull request Dec 4, 2019
e.g. `plot([1, 2], ls=(None, (4, 4)))` which was previously a synonym
for `plot([1, 2], ls=(0, (4, 4)))` which means "dash-pattern of
4pt-long dashes separated by 4pt spaces, with an offset of 0pt at
start".

Passing None instead of 0 was already not (likely, never) supported for
pdf, ps, or svg (an exception is raised at savefig() time for ps/svg, an
invalid pdf is generated).  There isn't much of a point in supporting
None (this also makes e.g. mplcairo more complex because of static
typing in C++ extensions), so just deprecate it.
@dstansby
Copy link
Member
dstansby commented Dec 4, 2019

Is there an easy way to check these are thrown in the test suite?

@anntzer
Copy link
Contributor Author
anntzer commented Dec 4, 2019

We don't bother doing that for regular deprecations (and the test suite wouldn't have caught this anyways because pytest reenables DeprecationWarnings).

@dstansby
Copy link
Member
dstansby commented Dec 4, 2019

I thought we did keep tests for deprecated stuff in the test suite, and just caught the deprecation warning? Anyway, these seem obscure enough not to insist on tests being added.

@anntzer
Copy link
Contributor Author
anntzer commented Dec 4, 2019

We did that if the things were already being tested, but for untested APIs getting deprecated (which occurs quite often because they're typically obscure...), we didn't bother adding tests for them just checking the deprecation.

@dstansby dstansby merged commit 582ba33 into matplotlib:master Dec 4, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Dec 4, 2019
@anntzer anntzer deleted the cfutw branch December 4, 2019 10:53
tacaswell added a commit that referenced this pull request Dec 5, 2019
…829-on-v3.2.x

Backport PR #15829 on branch v3.2.x (In C extensions, use FutureWarning, not DeprecationWarning.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0