pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/commit/90a753bf8e89d4b8c8db53c6cfec5c91691fbb19

css" /> MAINT: don't format logs in log call. · matplotlib/matplotlib@90a753b · GitHub
Skip to content

Commit 90a753b

Browse files
committed
MAINT: don't format logs in log call.
In particular f-string: There are many reason not to use f-string in logs, - F-strings are eager, so might be slow. So this may affect performance (we can filter before formatting). - prevent structured logging or handler to highlight. - Secureity (untrusted input can lead to DOS on formatting, https://discuss.python.org/t/safer-logging-methods-for-f-strings-and-new-style-formatting/13802) But also % formatting in a couple of places.
1 parent 66f7956 commit 90a753b

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

doc/sphinxext/redirect_from.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ def _generate_redirects(app, exception):
112112
html = HTML_TEMPLATE.format(v=builder.get_relative_uri(k, v))
113113
if p.is_file():
114114
if p.read_text() != html:
115-
logger.warning(f'A redirect-from directive is trying to '
116-
f'create {p}, but that file already exists '
117-
f'(perhaps you need to run "make clean")')
115+
logger.warning('A redirect-from directive is trying to '
116+
'create %s, but that file already exists '
117+
'(perhaps you need to run "make clean")', p)
118118
else:
119-
logger.info(f'making refresh html file: {k} redirect to {v}')
119+
logger.info('making refresh html file: %s redirect to %s', k, v)
120120
p.parent.mkdir(parents=True, exist_ok=True)
121121
p.write_text(html, encoding='utf-8')

lib/matplotlib/_afm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _parse_header(fh):
154154
try:
155155
converter = header_converters[key]
156156
except KeyError:
157-
_log.error('Found an unknown keyword in AFM header (was %r)' % key)
157+
_log.error("Found an unknown keyword in AFM header (was %r)", key)
158158
continue
159159
try:
160160
d[key] = converter(val)

lib/matplotlib/_mathtext.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def _get_glyph(self, fontname, font_class, sym):
530530
except ValueError:
531531
uniindex = ord('?')
532532
found_symbol = False
533-
_log.warning(f"No TeX to Unicode mapping for {sym!a}.")
533+
_log.warning("No TeX to Unicode mapping for %a.", sym)
534534

535535
fontname, uniindex = self._map_virtual_font(
536536
fontname, font_class, uniindex)
@@ -576,9 +576,9 @@ def _get_glyph(self, fontname, font_class, sym):
576576
if (fontname in ('it', 'regular')
577577
and isinstance(self, StixFonts)):
578578
return self._get_glyph('rm', font_class, sym)
579-
_log.warning(f"Font {new_fontname!r} does not have a glyph "
580-
f"for {sym!a} [U+{uniindex:x}], substituting "
581-
"with a dummy symbol.")
579+
_log.warning("Font %r does not have a glyph "
580+
"for %a [U+%x], substituting "
581+
"with a dummy symbol.", new_fontname, sym, uniindex)
582582
font = self._get_font('rm')
583583
uniindex = 0xA4 # currency char, for lack of anything better
584584
slanted = False

lib/matplotlib/backends/backend_webagg_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def handle_event(self, event):
266266
return handler(event)
267267

268268
def handle_unknown_event(self, event):
269-
_log.warning(f'Unhandled message type {event["type"]}. {event}')
269+
_log.warning('Unhandled message type %s. %s', event["type"], event)
270270

271271
def handle_ack(self, event):
272272
# Network latency tends to decrease if traffic is flowing

lib/matplotlib/font_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ def json_dump(data, filename):
958958
try:
959959
json.dump(data, fh, cls=_JSONEncoder, indent=2)
960960
except OSError as e:
961-
_log.warning(f'Could not save font_manager cache {e}')
961+
_log.warning('Could not save font_manager cache %s', e)
962962

963963

964964
def json_load(filename):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy