Content-Length: 1494 | pFad | http://github.com/gitpython-developers/GitPython/pull/1639.patch
thub.com
From 3e829eb516a60212bae81a6549361be4748e22d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?=
=?UTF-8?q?=E0=A4=A4=29?=
Date: Sat, 2 Sep 2023 14:21:03 +0545
Subject: [PATCH] util: close lockfile after opening successfully
Otherwise, this will leak file handles and can be a problem in Windows.
Also, `closefd=true` is the default here, so need to pass it explicitly.
Regression from #1619.
I noticed after [our tests started raising `ResourceWarning`][1].
```python
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.8.17/x64/lib/python3.8/site-packages/git/util.py", line 938, in _obtain_lock_or_raise
open(lock_file, mode='w', closefd=True)
ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/pytest-of-runner/pytest-0/popen-gw0/external0/project.git/.git/config.lock' mode='w' encoding='UTF-8'>
```
[1]: https://github.com/iterative/dvc/actions/runs/6055520480/job/16434544764#step:6:869
---
git/util.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/git/util.py b/git/util.py
index a3748f0fe..f6dedf0f2 100644
--- a/git/util.py
+++ b/git/util.py
@@ -935,7 +935,8 @@ def _obtain_lock_or_raise(self) -> None:
)
try:
- open(lock_file, mode='w', closefd=True)
+ with open(lock_file, mode='w'):
+ pass
except OSError as e:
raise IOError(str(e)) from e
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/gitpython-developers/GitPython/pull/1639.patch
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy