In some sense - you had a bad file that was getting processed - and
the script gave you an error. - And from the stack trace - you could
determine and delete the bad file - so its a good thing?
But I guess the functionality issue here is - this script should
ignore ".#*" (or ".*") files? [A bit hacky patch here]:
Satish
---------
balay@p1 /home/balay/petsc (main =)
$ touch include/.#petscsystypes.h
balay@p1 /home/balay/petsc (main =)
$ chmod a-rwx include/.#petscsystypes.h
balay@p1 /home/balay/petsc (main =)
$ ./lib/petsc/bin/maint/check_header_guard.py --action=check --kind=pragma_once
-- ./src ./include
Traceback (most recent call last):
File "/home/balay/petsc/./lib/petsc/bin/maint/check_header_guard.py", line
508, in <module>
ret = command_line_main()
File "/home/balay/petsc/./lib/petsc/bin/maint/check_header_guard.py", line
495, in command_line_main
ret = main(args)
File "/home/balay/petsc/./lib/petsc/bin/maint/check_header_guard.py", line
436, in main
errors.extend(replace_in_file(dirpath / f, args, replacer_cls))
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/balay/petsc/./lib/petsc/bin/maint/check_header_guard.py", line
369, in replace_in_file
lines = path.read_text().splitlines()
~~~~~~~~~~~~~~^^
File "/usr/lib64/python3.14/pathlib/__init__.py", line 787, in read_text
with self.open(mode='r', encoding=encoding, errors=errors, newline=newline)
as f:
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.14/pathlib/__init__.py", line 771, in open
return io.open(self, mode, buffering, encoding, errors, newline)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied:
'/home/balay/petsc/include/.#petscsystypes.h'
balay@p1 /home/balay/petsc (main =)
$ cat fix.diff
diff --git a/lib/petsc/bin/maint/check_header_guard.py
b/lib/petsc/bin/maint/check_header_guard.py
index f246fd62890..b56528e8bc3 100755
--- a/lib/petsc/bin/maint/check_header_guard.py
+++ b/lib/petsc/bin/maint/check_header_guard.py
@@ -432,7 +432,7 @@ def main(args: argparse.Namespace) -> int:
dirs[:] = [d for d in dirs if d not in exclude_dirs]
dirpath = pathlib.Path(dirname)
for f in files:
- if f not in exclude_files:
+ if f not in exclude_files and not f.startswith('.#'):
errors.extend(replace_in_file(dirpath / f, args, replacer_cls))
if errors:
balay@p1 /home/balay/petsc (main =)
$ patch -Np1 < fix.diff
patching file lib/petsc/bin/maint/check_header_guard.py
balay@p1 /home/balay/petsc (main *=)
$ ./lib/petsc/bin/maint/check_header_guard.py --action=check --kind=pragma_once
-- ./src ./include
balay@p1 /home/balay/petsc (main *=)
$ echo $?
0
On Sat, 24 Jan 2026, Barry Smith wrote:
>
> $ make checkbadSource
> Traceback (most recent call last):
> File
> "/Users/barrysmith/Src/petsc/lib/petsc/bin/maint/check_header_guard.py", line
> 508, in <module>
> ret = command_line_main()
> File
> "/Users/barrysmith/Src/petsc/lib/petsc/bin/maint/check_header_guard.py", line
> 495, in command_line_main
> ret = main(args)
> File
> "/Users/barrysmith/Src/petsc/lib/petsc/bin/maint/check_header_guard.py", line
> 436, in main
> errors.extend(replace_in_file(dirpath / f, args, replacer_cls))
> File
> "/Users/barrysmith/Src/petsc/lib/petsc/bin/maint/check_header_guard.py", line
> 369, in replace_in_file
> lines = path.read_text().splitlines()
> File
> "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/pathlib.py",
> line 1256, in read_text
> with self.open(mode='r', encoding=encoding, errors=errors) as f:
> File
> "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/pathlib.py",
> line 1242, in open
> return io.open(self, mode, buffering, encoding, errors, newline,
> File
> "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/pathlib.py",
> line 1110, in _opener
> return self._accessor.open(self, flags, mode)
> FileNotFoundError: [Errno 2] No such file or directory:
> '/Users/barrysmith/Src/petsc/include/.#petscsystypes.h'
> make[1]: [checkbadSource] Error 1 (ignored)
> ^Cmake: *** [checkbadSource] Interrupt: 2
>
> ~/Src/petsc (barry/2026-01-13/ftn-generation-for-context-functions *=)
> arch-ftn-generation-for-context-functions
> $ rm /Users/barrysmith/Src/petsc/include/.#petscsystypes.h
> ~/Src/petsc (barry/2026-01-13/ftn-generation-for-context-functions *=)
> arch-ftn-generation-for-context-functions
> $ checkbadSource
> -bash: checkbadSource: command not found
> ~/Src/petsc (barry/2026-01-13/ftn-generation-for-context-functions *=)
> arch-ftn-generation-for-context-functions
> $ make checkbadSource
> ~/Src/petsc (barry/2026-01-13/ftn-generation-for-context-functions *=)
>
>
>