From 3eb05f86efb7ac8b15ca952246e0160de16ad4e0 Mon Sep 17 00:00:00 2001 From: Joerg Henrichs Date: Wed, 22 Apr 2026 12:15:47 +1000 Subject: [PATCH 1/2] #503 Remove unnecessary tests for preprocessor directives. --- src/fparser/two/utils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/fparser/two/utils.py b/src/fparser/two/utils.py index 7a179d2e..a2f3e3b7 100644 --- a/src/fparser/two/utils.py +++ b/src/fparser/two/utils.py @@ -712,15 +712,14 @@ def match( if reader.process_directives: comments.insert(0, di.Directive) classes = subclasses + comments - # Preprocessor directives are always valid sub-classes - cpp_classes = [ - getattr(di.C99Preprocessor, cls_name) - for cls_name in di.C99Preprocessor.CPP_CLASS_NAMES - ] - classes += cpp_classes if endcls is not None: classes += [endcls] endcls_all = tuple([endcls] + endcls.subclasses[endcls.__name__]) + # Preprocessor directives are always valid sub-classes. While + # `match_cpp_directive` is a function, it behaves correctly here + # returning either None or an instance, so we can just add it to + # the classes that will be tested. + classes.append(di.C99Preprocessor.match_cpp_directive) try: # Start trying to match the various subclasses, starting from From bd50fc65ea5b48961976c773597d5323180ac760 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Mon, 27 Apr 2026 09:29:31 +0100 Subject: [PATCH 2/2] #503 Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2971f7ef..b477165f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,11 @@ Modifications by (in alphabetical order): * P. Vitt, University of Siegen, Germany * A. Voysey, UK Met Office + +27/04/2026 PR #504 for #503. Improve preprocessor directives parsing. + +## Release 0.2.2 (19/03/2026) ## + 19/03/2026 PR #496. Add support for F2008 unlimited-format-item. 13/03/2026 PR #495 for #494. Fix CI issues with the black formatting check.