From: Ricardo Ribalda <ribalda@chromium.org>
To: Thomas Gleixner <tglx@linutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org, linux-kernel@vger.kernel.org,
Ricardo Ribalda <ribalda@chromium.org>
Subject: [PATCH] scripts/spdxcheck: Limit the scope of git.Repo
Date: Tue, 25 Feb 2025 13:10:41 +0000 [thread overview]
Message-ID: <20250225-spx-v1-1-e935b27eb80d@chromium.org> (raw)
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 <ribalda@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 <ribalda@chromium.org>
next reply other threads:[~2025-02-25 13:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 13:10 Ricardo Ribalda [this message]
2025-04-03 21:34 ` Ricardo Ribalda
2025-04-04 6:21 ` Greg Kroah-Hartman
2025-04-04 6:29 ` Ricardo Ribalda
2025-04-04 8:06 ` Greg Kroah-Hartman
2025-04-07 14:38 ` Duje Mihanović
2025-04-08 8:39 ` Gon Solo
2025-04-08 9:33 ` Gon Solo
2025-04-08 10:36 ` Gon Solo
2025-04-08 17:34 ` spdxcheck: python git module considered harmful (was RE: [PATCH] scripts/spdxcheck: Limit the scope of git.Repo) Bird, Tim
2025-04-08 18:10 ` Greg Kroah-Hartman
2025-04-08 21:39 ` Ricardo Ribalda
2025-04-08 23:41 ` Thomas Gleixner
2025-04-09 17:44 ` Bird, Tim
2025-04-09 20:25 ` Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250225-spx-v1-1-e935b27eb80d@chromium.org \
--to=ribalda@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spdx@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®