Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1ddf953

Browse filesBrowse files
committed
Fix TemporaryFileSwap bug when file_path is a Path
This fixes the regression introduced in 9e86053 (#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 #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
Copy full SHA for 1ddf953

File tree

1 file changed

+1
-1
lines changed
Filter options

1 file changed

+1
-1
lines changed

‎git/index/util.py

Copy file name to clipboardExpand all lines: git/index/util.py
+1-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.