From 0edca2f2d4100d9e820c83e9258a956d38bd6696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Thu, 9 Jul 2026 16:01:06 -0400 Subject: [PATCH 1/2] gui: Actually raise GExceptions in iscatt_core Some code in iscatt was not raising the exception it was creating. Thus, it was not having any effect. Here is the PR text for one of the fixes that was generated by AI. I did the others. General fix: when an error condition is detected, **raise** the exception instead of just constructing it. Best fix here: in `gui/wxpython/iscatt/iscatt_core.py`, inside `CatRastUpdater._updateCatRast`, change line 277 from: - `GException(_("Patching category raster conditions file failed."))` to: - `raise GException(_("Patching category raster conditions file failed."))` This preserves intended functionality (error reporting via `GException`) while ensuring the failure is not silently ignored. No new imports, methods, or definitions are required. --- gui/wxpython/iscatt/core_c.py | 2 +- gui/wxpython/iscatt/iscatt_core.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gui/wxpython/iscatt/core_c.py b/gui/wxpython/iscatt/core_c.py index 93f90e6a2ee..b1766ab33b7 100644 --- a/gui/wxpython/iscatt/core_c.py +++ b/gui/wxpython/iscatt/core_c.py @@ -82,7 +82,7 @@ def ApplyColormap(vals, vals_mask, colmap, out_vals): def MergeArrays(merged_arr, overlay_arr, alpha): if merged_arr.shape != overlay_arr.shape: - GException("MergeArrays: merged_arr.shape != overlay_arr.shape") + raise GException("MergeArrays: merged_arr.shape != overlay_arr.shape") c_uint8_p = POINTER(c_uint8) merged_p = merged_arr.ctypes.data_as(c_uint8_p) diff --git a/gui/wxpython/iscatt/iscatt_core.py b/gui/wxpython/iscatt/iscatt_core.py index 8ad40df672a..abf42ad12a1 100644 --- a/gui/wxpython/iscatt/iscatt_core.py +++ b/gui/wxpython/iscatt/iscatt_core.py @@ -139,7 +139,7 @@ def ComputeCatsScatts(self, cats_ids): ) if returncode < 0: - GException(_("Computing of scatter plots failed.")) + raise GException(_("Computing of scatter plots failed.")) def CatRastUpdater(self): return self.cat_rast_updater @@ -274,7 +274,7 @@ def _updateCatRast(self, bbox, areas_cats, updated_cats): region = self.an_data.GetRegion() ret = UpdateCatRast(patch_rast, region, self.scatts_dt.GetCatRastCond(cat)) if ret < 0: - GException(_("Patching category raster conditions file failed.")) + raise GException(_("Patching category raster conditions file failed.")) RunCommand("g.remove", flags="f", type="raster", name=patch_rast) def _rasterize(self, grass_region, layer, cat, out_rast): @@ -296,7 +296,7 @@ def _rasterize(self, grass_region, layer, cat, out_rast): ) if ret != 0: - GException(_("v.build failed:\n%s") % msg) + raise GException(_("v.build failed:\n%s") % msg) environs = os.environ.copy() environs["GRASS_REGION"] = grass_region["GRASS_REGION"] @@ -316,7 +316,7 @@ def _rasterize(self, grass_region, layer, cat, out_rast): ) if ret != 0: - GException(_("v.to.rast failed:\n{messages}").format(messages=msg)) + raise GException(_("v.to.rast failed:\n{messages}").format(messages=msg)) def _create_grass_region_env(self, bbox): r = self.an_data.GetRegion() @@ -383,7 +383,7 @@ def Create(self, bands): self.region = GetRegion() if self.region["rows"] * self.region["cols"] > MAX_NCELLS: - GException("too big region") + raise GException("too big region") self.bands_info = {} @@ -391,7 +391,7 @@ def Create(self, bands): i = GetRasterInfo(b) if i is None: - GException("raster %s is not CELL type" % (b)) + raise GException("raster %s is not CELL type" % (b)) self.bands_info[b] = i # TODO check size of raster From 6033b57ae6adeb63505dbb825b25e277ab480ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Thu, 9 Jul 2026 16:33:29 -0400 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- gui/wxpython/iscatt/core_c.py | 3 ++- gui/wxpython/iscatt/iscatt_core.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gui/wxpython/iscatt/core_c.py b/gui/wxpython/iscatt/core_c.py index b1766ab33b7..1af6fe11186 100644 --- a/gui/wxpython/iscatt/core_c.py +++ b/gui/wxpython/iscatt/core_c.py @@ -82,7 +82,8 @@ def ApplyColormap(vals, vals_mask, colmap, out_vals): def MergeArrays(merged_arr, overlay_arr, alpha): if merged_arr.shape != overlay_arr.shape: - raise GException("MergeArrays: merged_arr.shape != overlay_arr.shape") + msg = "MergeArrays: merged_arr.shape != overlay_arr.shape" + raise GException(msg) c_uint8_p = POINTER(c_uint8) merged_p = merged_arr.ctypes.data_as(c_uint8_p) diff --git a/gui/wxpython/iscatt/iscatt_core.py b/gui/wxpython/iscatt/iscatt_core.py index abf42ad12a1..063e2cca08b 100644 --- a/gui/wxpython/iscatt/iscatt_core.py +++ b/gui/wxpython/iscatt/iscatt_core.py @@ -383,7 +383,8 @@ def Create(self, bands): self.region = GetRegion() if self.region["rows"] * self.region["cols"] > MAX_NCELLS: - raise GException("too big region") + msg = "too big region" + raise GException(msg) self.bands_info = {}