From 17cda727442bea4c62ed9de954c4d6527bda2df8 Mon Sep 17 00:00:00 2001 From: y1thof Date: Thu, 7 Jun 2018 14:34:24 +0200 Subject: [PATCH] Fix: issue PendingDeprecationWarnings when pending=True --- lib/matplotlib/cbook/deprecation.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/cbook/deprecation.py b/lib/matplotlib/cbook/deprecation.py index 9c8c83225ba7..2df87d17e187 100644 --- a/lib/matplotlib/cbook/deprecation.py +++ b/lib/matplotlib/cbook/deprecation.py @@ -75,7 +75,7 @@ def warn_deprecated( pending : bool, optional If True, uses a PendingDeprecationWarning instead of a - DeprecationWarning. + MatplotlibDeprecationWarning. removal : str, optional The expected removal version. With the default (an empty string), a @@ -100,7 +100,8 @@ def warn_deprecated( """ message = _generate_deprecation_message( since, message, name, alternative, pending, obj_type, removal=removal) - warnings.warn(message, mplDeprecation, stacklevel=2) + warn_cls = PendingDeprecationWarning if pending else mplDeprecation + warnings.warn(message, warn_cls, stacklevel=2) def deprecated(since, message='', name='', alternative='', pending=False, @@ -140,7 +141,7 @@ def new_function(): pending : bool, optional If True, uses a PendingDeprecationWarning instead of a - DeprecationWarning. + MatplotlibDeprecationWarning. removal : str, optional The expected removal version. With the default (an empty string), a @@ -205,7 +206,8 @@ def finalize(wrapper, new_doc): removal=removal) def wrapper(*args, **kwargs): - warnings.warn(message, mplDeprecation, stacklevel=2) + warn_cls = PendingDeprecationWarning if pending else mplDeprecation + warnings.warn(message, warn_cls, stacklevel=2) return func(*args, **kwargs) old_doc = textwrap.dedent(old_doc or '').strip('\n')