diff --git a/src/psyclone/psyir/frontend/fortran.py b/src/psyclone/psyir/frontend/fortran.py index 77b7c5c859..98285bbd6d 100644 --- a/src/psyclone/psyir/frontend/fortran.py +++ b/src/psyclone/psyir/frontend/fortran.py @@ -72,6 +72,9 @@ class FortranReader(): for more precise control it also accepts a list of module names. Defaults to False. + :raises ValueError: If ignore_directives is set to False but + ignore_comments is set to True. + ''' # Save parser object across instances to reduce the initialisation time _parser = None @@ -85,8 +88,8 @@ def __init__(self, free_form: bool = True, ignore_comments: bool = True, self._free_form = free_form if ignore_comments and not ignore_directives: raise ValueError( - "Setting ignore_directives to False will only have an effect" - " if ignore_comments is also set to False" + "Setting ignore_directives to False in the FortranReader will" + " only have an effect if ignore_comments is also set to False." ) self._ignore_comments = ignore_comments self._processor = Fparser2Reader(ignore_directives, diff --git a/src/psyclone/tests/psyir/frontend/fortran_test.py b/src/psyclone/tests/psyir/frontend/fortran_test.py index 9cd3579ce4..e7c708c749 100644 --- a/src/psyclone/tests/psyir/frontend/fortran_test.py +++ b/src/psyclone/tests/psyir/frontend/fortran_test.py @@ -280,7 +280,7 @@ def test_fortran_psyir_from_file(fortran_reader, tmpdir_factory): with pytest.raises(ValueError) as err: FortranReader(ignore_comments=True, ignore_directives=False) msg = ( - "Setting ignore_directives to False will only have an effect if" - " ignore_comments is also set to False" + "Setting ignore_directives to False in the FortranReader will" + " only have an effect if ignore_comments is also set to False." ) assert msg in str(err.value)