Skip to content

Commit a27a1b4

Browse files
committed
python framework: improve debugging
also import util module Signed-off-by: Howard Pritchard <[email protected]>
1 parent ff26f79 commit a27a1b4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ompi/mpi/bindings/ompi_bindings/parser.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2024 Triad National Security, LLC. All rights
1+
# Copyright (c) 2024-2025 Triad National Security, LLC. All rights
22
# reserved.
33
#
44
# $COPYRIGHT$
@@ -9,6 +9,7 @@
99

1010
import os
1111
import sys
12+
from ompi_bindings import util
1213

1314
"""Source parsing code."""
1415

@@ -75,7 +76,7 @@ def signature(self, fn_name, enable_count=False, **kwargs):
7576
return f'{return_type_text} {fn_name}({params})'
7677

7778

78-
def validate_body(body):
79+
def validate_body(fname, body):
7980
"""Validate the body of a template."""
8081
# Just do a simple bracket balance test to determine the bounds of the
8182
# function body. All lines after the function body should be blank. There
@@ -86,15 +87,15 @@ def validate_body(body):
8687
for line in body:
8788
line = line.strip()
8889
if bracket_balance == 0 and line_count > 0 and line:
89-
raise util.BindingError('Extra code found in template; only one function body is allowed')
90+
raise util.BindingError('Extra code found in template %s; only one function body is allowed' % str(fname))
9091

9192
update = line.count('{') - line.count('}')
9293
bracket_balance += update
9394
if bracket_balance != 0:
9495
line_count += 1
9596

9697
if bracket_balance != 0:
97-
raise util.BindingError('Mismatched brackets found in template')
98+
raise util.BindingError('Mismatched brackets found in template ' + str(fname))
9899

99100

100101
class SourceTemplate:
@@ -141,7 +142,7 @@ def load(fname, prefix=None, type_constructor=None):
141142
params = [Parameter(param, type_constructor=type_constructor) for param in params]
142143
prototype = Prototype(name, return_type, params)
143144
# Ensure the body contains only one function
144-
validate_body(body)
145+
validate_body(fname, body)
145146
return SourceTemplate(prototype, header, body)
146147

147148
def print_header(self, out):

0 commit comments

Comments
 (0)