Skip to content
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

wxGUI: Fixed bare except in mapwin/ #5010

Merged
merged 5 commits into from
Jan 30, 2025
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: 0 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ per-file-ignores =
gui/wxpython/iclass/g.gui.iclass.py: E501
gui/wxpython/mapdisp/test_mapdisp.py: E501
gui/wxpython/mapswipe/g.gui.mapswipe.py: E501
gui/wxpython/mapwin/base.py: E722
gui/wxpython/mapwin/buffered.py: E722
gui/wxpython/timeline/g.gui.timeline.py: E501
# Generated file
gui/wxpython/menustrings.py: E501
# C wrappers call libgis.G_gisinit before importing other modules.
# TODO: Is this really needed?
python/grass/jupyter/__init__.py: E501
python/grass/pygrass/vector/__init__.py: E402
# Configuration file for Sphinx:
# Ignoring import/code mix and line length.
# Files not managed by Black
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/mapwin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def HandlersCaller(self, event, handlers):
for handler in handlers:
try:
handler(event)
except:
except Exception:
handlers.remove(handler)
GError(
parent=self,
Expand Down Expand Up @@ -308,7 +308,7 @@ def UnregisterAllHandlers(self):
try:
handler("unregistered")
handlers.remove(handler)
except:
except Exception:
GError(
parent=self,
message=_(
Expand Down Expand Up @@ -347,7 +347,7 @@ def UnregisterMouseEventHandler(self, event, handler):
grass.warning(
_("Handler: %s was not registered") % handler.__name__
)
except:
except Exception:
GError(
parent=self,
message=_(
Expand Down
20 changes: 7 additions & 13 deletions gui/wxpython/mapwin/buffered.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ def _updateMFinished(self, renderVector=True):
for item in self.graphicsSetList:
try:
item.Draw()
except:
except Exception:
GError(
parent=self,
message=_(
Expand Down Expand Up @@ -1180,10 +1180,7 @@ def MouseDraw(self, pdc=None, begin=None, end=None):
if isinstance(r, list):
r = Rect(r[0], r[1], r[2], r[3])
r.Inflate(4, 4)
try:
pdc.ClearId(boxid)
except:
pass
pdc.ClearId(boxid)
self.RefreshRect(r, False)
pdc.SetId(boxid)
self.Draw(pdc, drawid=boxid, pdctype="box", coords=mousecoords)
Expand All @@ -1197,10 +1194,7 @@ def MouseDraw(self, pdc=None, begin=None, end=None):
y2 = max(begin[1], end[1])
r = Rect(x1, y1, x2 - x1, y2 - y1)
r.Inflate(4, 4)
try:
pdc.ClearId(self.lineid)
except:
pass
pdc.ClearId(self.lineid)
self.RefreshRect(r, False)
pdc.SetId(self.lineid)
self.Draw(pdc, drawid=self.lineid, pdctype="line", coords=mousecoords)
Expand Down Expand Up @@ -1736,13 +1730,13 @@ def ClearLines(self, pdc=None):
try:
pdc.ClearId(self.lineid)
pdc.RemoveId(self.lineid)
except:
except (KeyError, TypeError):
pass

try:
pdc.ClearId(self.plineid)
pdc.RemoveId(self.plineid)
except:
except (KeyError, TypeError):
pass

Debug.msg(
Expand All @@ -1764,7 +1758,7 @@ def Pixel2Cell(self, xyCoords):
try:
x = int(xyCoords[0])
y = int(xyCoords[1])
except:
except (TypeError, ValueError, IndexError):
return None

if self.Map.region["ewres"] > self.Map.region["nsres"]:
Expand All @@ -1785,7 +1779,7 @@ def Cell2Pixel(self, enCoords):
try:
east = float(enCoords[0])
north = float(enCoords[1])
except:
except (TypeError, ValueError, IndexError):
return None

if self.Map.region["ewres"] > self.Map.region["nsres"]:
Expand Down
Loading