From d1e61c719a7306c8c22cbd35d13e47d03b5b71dd Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Mon, 15 Jun 2026 16:19:47 +0100 Subject: [PATCH 1/3] #512 fix circular import and add test to prevent regression --- .../tests/fortran2008/test_f2008_import.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/fparser/two/tests/fortran2008/test_f2008_import.py diff --git a/src/fparser/two/tests/fortran2008/test_f2008_import.py b/src/fparser/two/tests/fortran2008/test_f2008_import.py new file mode 100644 index 00000000..ae7ee862 --- /dev/null +++ b/src/fparser/two/tests/fortran2008/test_f2008_import.py @@ -0,0 +1,52 @@ +# Copyright (c) 2026 Science and Technology Facilities Council + +# All rights reserved. + +# Modifications made as part of the fparser project are distributed +# under the following license: + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: + +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. + +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. + +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import sys +import subprocess + +"""Tests for the Fortran2008 module as a whole.""" + + +def test_fortran2008_import_without_fortran2003_first(): + """ + Check that `from fparser.two import Fortran2008` works in a + fresh interpreter, i.e. without Fortran2003 having been + imported first (which previously masked a circular import bug). + """ + result = subprocess.run( + [sys.executable, "-c", "from fparser.two import Fortran2008"], + capture_output=True, + text=True, + ) + assert result.returncode == 0, result.stderr From d7183b08d8255ac535e6d05647b954728e7d36f3 Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Mon, 15 Jun 2026 16:20:19 +0100 Subject: [PATCH 2/3] #512 actually include the bug fix --- src/fparser/two/Fortran2008/label_do_stmt_r816.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/fparser/two/Fortran2008/label_do_stmt_r816.py b/src/fparser/two/Fortran2008/label_do_stmt_r816.py index 09ec2db5..c62d41a5 100644 --- a/src/fparser/two/Fortran2008/label_do_stmt_r816.py +++ b/src/fparser/two/Fortran2008/label_do_stmt_r816.py @@ -1,7 +1,7 @@ # ----------------------------------------------------------------------------- # BSD 3-Clause License # -# Copyright (c) 2023, Science and Technology Facilities Council. +# Copyright (c) 2023-2026, Science and Technology Facilities Council. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -37,12 +37,12 @@ label-do-stmt is [ do-construct-name : ] DO label [ loop-control ] The only difference to F2003 rule R828 is that we force this rule to -use the F2008 version of loop-control +use the F2008 version of loop-control. """ from fparser.two.Fortran2003 import Label_Do_Stmt as Label_Do_Stmt_2003 -from fparser.two.Fortran2008 import Loop_Control +from fparser.two.Fortran2008.loop_control_r818 import Loop_Control class Label_Do_Stmt(Label_Do_Stmt_2003): @@ -52,10 +52,8 @@ class Label_Do_Stmt(Label_Do_Stmt_2003): """ @staticmethod - def loop_control_cls(): + def loop_control_cls() -> Loop_Control: """ :returns: Fortran2008 Loop_Control class. - :rtype: :py:class:`fparser.two.Fortran2008.Loop_Control` - """ return Loop_Control From 89facdec9e28120b08bb8712423b3a4a6c9263e9 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Fri, 19 Jun 2026 09:39:27 +0100 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index abcfea39..2534268f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ Modifications by (in alphabetical order): * P. Vitt, University of Siegen, Germany * A. Voysey, UK Met Office +19/06/2026 PR #513 for #512. Fix circular import in Fortran2008. + ## Release 0.2.3 (11/06/2026) ## 09/06/2026 PR #498 for #390 by adding support for linemarkers in parsed