Skip to content

Commit

Permalink
BUG: handle not found file in surface_from_file
Browse files Browse the repository at this point in the history
surface_from_file would throw a segfault when file is missing,
fixed with a check on the python side.
  • Loading branch information
eivindjahren committed Dec 21, 2021
1 parent 6b42e34 commit 88f2b6d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/xtgeo/surface/regular_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,7 @@ def _read_file(
"""
mfile = xtgeosys._XTGeoFile(mfile)
mfile.check_file(raiseerror=ValueError)
if fformat is None or fformat == "guess":
fformat = mfile.detect_fformat()
else:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_surface/test_regular_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
FENCE1 = TPATH / "polygons/reek/1/fence.pol"


def test_surface_from_file_missing(tmp_path):
with pytest.raises(ValueError, match="missing"):
xtgeo.surface_from_file(tmp_path / "nosuchfile", fformat="irap_binary")


@pytest.mark.filterwarnings("ignore:Default values*")
def test_values(default_surface):
"""Test behaviour of values attribute."""
Expand Down

0 comments on commit 88f2b6d

Please sign in to comment.