Repository: DIAGNijmegen/rse-panimg (language: python)

Issue:
UnboundLocalError local variable 'simple_itk_image' referenced before assignment
panimg/image_builders/metaio_mhd_mha.py in image_builder_mhd at line 118

I think when an uploaded mha file fails metadata validation.


Discussion / hints:

Fix patch:
diff --git a/HISTORY.md b/HISTORY.md
index 956528f..23b68c7 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,5 +1,9 @@
 # History
 
+## 0.5.2 (2021-10-20)
+
+* Fix duplicate except clause
+
 ## 0.5.1 (2021-10-04)
 
 * Fix default values for extra metadata fields
diff --git a/panimg/__init__.py b/panimg/__init__.py
index c6457c3..7543e6e 100644
--- a/panimg/__init__.py
+++ b/panimg/__init__.py
@@ -1,4 +1,4 @@
-__version__ = "0.5.1"
+__version__ = "0.5.2"
 
 import logging
 
diff --git a/panimg/image_builders/metaio_mhd_mha.py b/panimg/image_builders/metaio_mhd_mha.py
index 8d0bb59..9dc4143 100644
--- a/panimg/image_builders/metaio_mhd_mha.py
+++ b/panimg/image_builders/metaio_mhd_mha.py
@@ -97,10 +97,6 @@ def format_error(message: str) -> str:
 
             try:
                 simple_itk_image = load_sitk_image(file.absolute())
-            except ValidationError as e:
-                file_errors[file].append(
-                    format_error(f"Could not validate file. {e}")
-                )
             except RuntimeError:
                 file_errors[file].append(
                     format_error("SimpleITK could not open file.")
diff --git a/pyproject.toml b/pyproject.toml
index 7239a50..f7ab7ea 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -31,7 +31,7 @@ commands =
 
 [tool.poetry]
 name = "panimg"
-version = "0.5.1"
+version = "0.5.2"
 description = "Conversion of medical images to MHA and TIFF."
 license = "Apache-2.0"
 authors = ["James Meakin <12661555+jmsmkn@users.noreply.github.com>"]


Test patch:
diff --git a/tests/test_panimg.py b/tests/test_panimg.py
index f0eb9c4..616b358 100644
--- a/tests/test_panimg.py
+++ b/tests/test_panimg.py
@@ -2,4 +2,4 @@
 
 
 def test_version():
-    assert __version__ == "0.5.1"
+    assert __version__ == "0.5.2"