public inbox for linux-spdx@vger.kernel.org
 help / color / mirror / Atom feed
From: Gon Solo <gonsolo@gmail.com>
To: "Duje Mihanović" <duje.mihanovic@skole.hr>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ricardo Ribalda <ribalda@chromium.org>,
	linux-spdx@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scripts/spdxcheck: Limit the scope of git.Repo
Date: Tue, 8 Apr 2025 11:33:17 +0200	[thread overview]
Message-ID: <Z_TtXaRnaU1zXbXv@pampelmuse> (raw)
In-Reply-To: <Z_Tgp8L_8goc63K1@pampelmuse>

> > checkpatch suddenly broke for me with the same error as shown here and the 
> > patch fixed it.
> > 
> > Tested-by: Duje Mihanović <duje.mihanovic@skole.hr>

Turns out, it was not enough; the variable is used later.
How about the following patch?

From 763f25c8ca2e29f343bfd109a17501de71b38d43 Mon Sep 17 00:00:00 2001
From: Andreas Wendleder <gonsolo@gmail.com>
Date: Tue, 8 Apr 2025 11:21:17 +0200
Subject: [PATCH] Fix spdxcheck.py.

As explained in Ricardo Ribalda's patch:

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 0x76e6b0148040>
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/lib/python3.13/subprocess.py", line 2227, in terminate
ImportError: sys.meta_path is None, Python is likely shutting down

Unfortunately, repo is used later at line 392 and 399, so we have to
keep it and manually delete it before exiting. This can be checked by
testing a directory instead of a file.

Signed-off--by: Andreas Wendleder <gonsolo@gmail.com>
---
 scripts/spdxcheck.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py
index 8d608f61bf37..6a89e2b2faba 100755
--- a/scripts/spdxcheck.py
+++ b/scripts/spdxcheck.py
@@ -448,6 +448,7 @@ if __name__ == '__main__':
                     for f in sorted(di.files):
                         sys.stderr.write('    %s\n' %f)
 
+            del repo
             sys.exit(0)
 
     except Exception as ex:
-- 
2.49.0


  reply	other threads:[~2025-04-08  9:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 13:10 [PATCH] scripts/spdxcheck: Limit the scope of git.Repo Ricardo Ribalda
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 [this message]
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=Z_TtXaRnaU1zXbXv@pampelmuse \
    --to=gonsolo@gmail.com \
    --cc=duje.mihanovic@skole.hr \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spdx@vger.kernel.org \
    --cc=ribalda@chromium.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