Seems as if my distro defaults now to Python 3.13 and that
is more sensitive - or it is due a change in a newer Git module.
At least I the following new exception showed up when using

./contrib/gcc-changelog/git_check_commit.py -v -p Exception ignored in: <function Git.AutoInterrupt.__del__ at 0x7ff995aa4f40> Traceback (most recent call last): File "/usr/lib/python3.13/site-packages/git/cmd.py", line 790, in __del__ File "/usr/lib/python3.13/site-packages/git/cmd.py", line 781, in _terminate File "/usr/lib64/python3.13/subprocess.py", line 2227, in terminate ImportError: sys.meta_path is None, Python is likely shutting down Seems as if the issue is that the lifetime of the destructor exceeds the Repo object lifetime. Others solved it in a similar way, for instance our kernel friends ("scripts/spdxcheck: Limit the scope of git.Repo"): https://lore.kernel.org/linux-spdx/20250225-spx-v1-1-e935b27eb...@chromium.org/T/#u
At least, the exception is gone after adding a 'repo.close()' before the
function returns.

Committed asr15-8068-g254549d2bb9bb3. Tobias
commit 254549d2bb9bb3c2719dec597427919c59514fc3
Author: Tobias Burnus <tbur...@baylibre.com>
Date:   Sat Mar 15 08:53:18 2025 +0100

    contrib/gcc-changelog: Fix Git.AutoInterrupt - sys.meta_path is None exception
    
    I think the following message is new with Python 3.13, at least I starting
    seeing the following exception, which could be fixed by a simple call
    to 'repo.close()'.
    
    Seemingly the issue was that the lifetime of the destructor exceeded the
    object lifetime.
    
      Exception ignored in: <function Git.AutoInterrupt.__del__ at 0x7ff995aa4f40>
      Traceback (most recent call last):
        File "/usr/lib/python3.13/site-packages/git/cmd.py", line 790, in __del__
        File "/usr/lib/python3.13/site-packages/git/cmd.py", line 781, in _terminate
        File "/usr/lib64/python3.13/subprocess.py", line 2227, in terminate
      ImportError: sys.meta_path is None, Python is likely shutting down
    
    contrib/ChangeLog:
    
            * gcc-changelog/git_repository.py (parse_git_revisions): Destroy the
            Repo object by calling repo.close() at the end of the function.

diff --git a/contrib/gcc-changelog/git_repository.py b/contrib/gcc-changelog/git_repository.py
index d7650c65e21..2b2efffe77a 100755
--- a/contrib/gcc-changelog/git_repository.py
+++ b/contrib/gcc-changelog/git_repository.py
@@ -78,4 +78,5 @@ def parse_git_revisions(repo_path, revisions, ref_name=None):
                                commit_to_info_hook=commit_to_info,
                                ref_name=ref_name)
         parsed_commits.append(git_commit)
+    repo.close()
     return parsed_commits

Reply via email to