From 8b7a0e59d318fbaf77d7197e1d55afbc6a614d3c Mon Sep 17 00:00:00 2001 From: Neil Shephard Date: Tue, 3 Jun 2025 14:26:51 +0100 Subject: [PATCH] bug: handle UnboundLocalError in Bruker files Closes #56 Adds another `except` to capture `UnboundLocalError` that arise in some Bruker files which appear to be a mixture of AFM/MFM. --- pySPM/Bruker.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pySPM/Bruker.py b/pySPM/Bruker.py index c7c696f..dfbd7d1 100644 --- a/pySPM/Bruker.py +++ b/pySPM/Bruker.py @@ -158,6 +158,8 @@ def get_channel( ) except KeyError: continue + except UnboundLocalError: + continue else: _type = "Bruker AFM" try: @@ -166,6 +168,8 @@ def get_channel( ) except KeyError: continue + except UnboundLocalError: + continue result = re.match(r'([^ ]+) \[([^]]*)] "([^"]*)"', layer_name).groups() if result[2] == channel: if debug: