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

Skip to content

Commit a695e93

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 a695e93

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-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: 7 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,11 @@ 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+
destroy = cbook._deprecate_method_override(
525+
__class__.destroy, self, since="3.4")
526+
if destroy:
527+
destroy()
523528
return result
524529

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

555+
@cbook.deprecated("3.4")
550556
def destroy(self):
551557
self.glyphd = None
552558
Fonts.destroy(self)

0 commit comments

Comments
 (0)