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