Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate the unneeded Fonts.destroy. #18003

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
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/api/next_api_changes/deprecations/18003-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mathtext.Fonts.destroy
~~~~~~~~~~~~~~~~~~~~~~
... is deprecated, because Fonts do not create reference loops anyways.
8 changes: 7 additions & 1 deletion lib/matplotlib/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ def __init__(self, default_font_prop, mathtext_backend):
self.mathtext_backend = mathtext_backend
self.used_characters = {}

@cbook.deprecated("3.4")
def destroy(self):
"""
Fix any cyclical references before the object is about
Expand Down Expand Up @@ -519,7 +520,11 @@ def get_results(self, box):
"""
result = self.mathtext_backend.get_results(
box, self.get_used_characters())
self.destroy()
if self.destroy != TruetypeFonts.destroy.__get__(self):
destroy = cbook._deprecate_method_override(
__class__.destroy, self, since="3.4")
if destroy:
destroy()
return result

def get_sized_alternatives_for_symbol(self, fontname, sym):
Expand Down Expand Up @@ -547,6 +552,7 @@ def __init__(self, default_font_prop, mathtext_backend):
self._fonts['default'] = default_font
self._fonts['regular'] = default_font

@cbook.deprecated("3.4")
def destroy(self):
self.glyphd = None
Fonts.destroy(self)
Expand Down