Re: [PATCH] scripts/spdxcheck: Limit the scope of git.Repo

From: Duje Mihanović
Date: Mon Apr 07 2025 - 10:54:25 EST


On Tuesday, 25 February 2025 14:10:41 Central European Summer Time Ricardo
Ribalda wrote:
> 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@xxxxxxxxxxxx>
> ---

checkpatch suddenly broke for me with the same error as shown here and the
patch fixed it.

Tested-by: Duje Mihanović <duje.mihanovic@xxxxxxxx>

Regards,
--
Duje