Skip to content

Commit

Permalink
v.surf.nnbathy: Fix exception type for Python 3 (#981)
Browse files Browse the repository at this point in the history
Fixes both v.surf.nnbathy and r.surf.nnbathy because r.surf.nnbathy imports the Python module installed with v.surf.nnbathy.

Fixes Pylint error E0602: Undefined variable 'StandardError' (undefined-variable), but introduces warning W0718: Catching too general exception Exception (broad-exception-caught).

This is aiming at making the tool run with Python 3 and GRASS GIS 8. Proper fix would separate try-except blocks to the relevant parts. Now two string splits, all vector handling and file writing are all in one try-except which catches everything including IndexError and AttributeError. This basic fix is just applying The Conservative Python 3 Porting Guide without further changes.
  • Loading branch information
wenzeslaus committed Nov 9, 2023
1 parent fc9c34d commit 1767c5f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/vector/v.surf.nnbathy/nnbathy.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def _load(self, options):
# fout.write(parts[0]+' '+parts[1]+' '+parts[4])
fout.write("{} {} {}".format(parts[0], parts[1], parts[4]))
pnt.close()
except (StandardError, OSError) as e:
except (Exception, OSError) as e:
grass.fatal_error("Invalid input: %s" % e)
fin.close()
fout.close()
Expand Down

0 comments on commit 1767c5f

Please sign in to comment.