From ec9a3b00aa53fe90dff707d7f1fd8bacc49a27a7 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Tue, 5 Nov 2024 23:08:59 -0500 Subject: [PATCH] wxGUI: Fixed bare 'except' for psmap/ (#4623) --- .flake8 | 2 +- gui/wxpython/psmap/frame.py | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.flake8 b/.flake8 index ab4038e4749..a44d0182e5f 100644 --- a/.flake8 +++ b/.flake8 @@ -24,7 +24,7 @@ per-file-ignores = gui/scripts/d.wms.py: E501 gui/wxpython/image2target/g.gui.image2target.py: E501 gui/wxpython/photo2image/g.gui.photo2image.py: E501 - gui/wxpython/psmap/*: E501, E722 + gui/wxpython/psmap/*: E501 gui/wxpython/vdigit/*: F841, E722, F405, F403 gui/wxpython/animation/g.gui.animation.py: E501 gui/wxpython/tplot/frame.py: F841, E722 diff --git a/gui/wxpython/psmap/frame.py b/gui/wxpython/psmap/frame.py index 54b5ca1a892..9598c0b0f71 100644 --- a/gui/wxpython/psmap/frame.py +++ b/gui/wxpython/psmap/frame.py @@ -1529,19 +1529,9 @@ def makePSFont(self, textDict): if "Bold" in fontstyle: weight = wx.FONTWEIGHT_BOLD - try: - fn = wx.Font( - pointSize=fontsize, family=family, style=style, weight=weight, face=face - ) - except: - fn = wx.Font( - pointSize=fontsize, - family=wx.FONTFAMILY_DEFAULT, - style=wx.FONTSTYLE_NORMAL, - weight=wx.FONTWEIGHT_NORMAL, - ) - - return fn + return wx.Font( + pointSize=fontsize, family=family, style=style, weight=weight, faceName=face + ) def getTextExtent(self, textDict): """Estimates bounding rectangle of text""" @@ -1555,7 +1545,7 @@ def getTextExtent(self, textDict): dc.SetFont(fn) w, h, lh = dc.GetFullMultiLineTextExtent(textDict["text"]) return (w, h) - except: + except (wx.PyAssertionError, ValueError, KeyError): return (0, 0) def getInitMap(self):