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

Skip to content

Commit 4831578

Browse files
committed
Deprecate the unneeded Fonts.destroy.
Neither `used_characters` nor `glyphd` cause circular references, so we can let the normal refcount collector handle the destruction.
1 parent 80848d2 commit 4831578

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mathtext.Fonts.destroy
2+
~~~~~~~~~~~~~~~~~~~~~~
3+
... is deprecated, because Fonts do not create reference loops anyways.

lib/matplotlib/mathtext.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ def __init__(self, default_font_prop, mathtext_backend):
398398
self.mathtext_backend = mathtext_backend
399399
self.used_characters = {}
400400

401+
@cbook.deprecated("3.4")
401402
def destroy(self):
402403
"""
403404
Fix any cyclical references before the object is about
@@ -519,7 +520,9 @@ def get_results(self, box):
519520
"""
520521
result = self.mathtext_backend.get_results(
521522
box, self.get_used_characters())
522-
self.destroy()
523+
if self.destroy != TruetypeFonts.destroy.__get__(self):
524+
cbook._deprecate_method_override(
525+
__class__.destroy, self, since="3.4")()
523526
return result
524527

525528
def get_sized_alternatives_for_symbol(self, fontname, sym):
@@ -547,6 +550,7 @@ def __init__(self, default_font_prop, mathtext_backend):
547550
self._fonts['default'] = default_font
548551
self._fonts['regular'] = default_font
549552

553+
@cbook.deprecated("3.4")
550554
def destroy(self):
551555
self.glyphd = None
552556
Fonts.destroy(self)

0 commit comments

Comments
 (0)