Skip to content

Commit 1ddf953

Browse files
committed
Fix TemporaryFileSwap bug when file_path is a Path
This fixes the regression introduced in 9e86053 (gitpython-developers#1770) where the file_path argument to TemporaryFileSwap.__init__ could no longer be a Path object. The change also makes this truer to the code from before gitpython-developers#1770, still without the race condition fixed there, in that str was called on file_path then as well. However, it is not clear that this is a good thing, because this is not an idiomatic use of mkstemp. The reason the `prefix` cannot be a Path is that it is expected to be a filename prefix, with leading directories given in the `dir` argument.
1 parent 487a4fd commit 1ddf953

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git/index/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TemporaryFileSwap:
4141

4242
def __init__(self, file_path: PathLike) -> None:
4343
self.file_path = file_path
44-
fd, self.tmp_file_path = tempfile.mkstemp(prefix=self.file_path, dir="")
44+
fd, self.tmp_file_path = tempfile.mkstemp(prefix=str(self.file_path), dir="")
4545
os.close(fd)
4646
with contextlib.suppress(OSError): # It may be that the source does not exist.
4747
os.replace(self.file_path, self.tmp_file_path)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy