If the git.Repo object's scope extends to the Python interpreter's shutdown phase, its destructor may fail due to the interpreter's state.
Exception ignored in: <function Git.AutoInterrupt.__del__ at 0x7f1941dd5620> Traceback (most recent call last): File "/usr/lib/python3/dist-packages/git/cmd.py", line 565, in __del__ File "/usr/lib/python3/dist-packages/git/cmd.py", line 546, in _terminate File "/usr/lib/python3.13/subprocess.py", line 2227, in terminate ImportError: sys.meta_path is None, Python is likely shutting down Use the `with` statement to limit the scope of git.Repo and ensure proper resource management. Signed-off-by: Ricardo Ribalda <riba...@chromium.org> --- scripts/spdxcheck.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py index 8d608f61bf37..eba808cbaeeb 100755 --- a/scripts/spdxcheck.py +++ b/scripts/spdxcheck.py @@ -349,11 +349,11 @@ if __name__ == '__main__': try: # Use git to get the valid license expressions - repo = git.Repo(os.getcwd()) - assert not repo.bare + with git.Repo(os.getcwd()) as repo: + assert not repo.bare - # Initialize SPDX data - spdx = read_spdxdata(repo) + # Initialize SPDX data + spdx = read_spdxdata(repo) # Initialize the parser parser = id_parser(spdx) --- base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6 change-id: 20250225-spx-382cf543370e Best regards, -- Ricardo Ribalda <riba...@chromium.org>