Ubuntu Pastebin

Paste from smoser at Thu, 3 Nov 2016 20:15:53 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
diff --git a/usd/GitRepository.py b/usd/GitRepository.py
index 391fccd..c69238c 100644
--- a/usd/GitRepository.py
+++ b/usd/GitRepository.py
@@ -448,15 +448,11 @@ class USDGitRepository:
             commit_tree += ['-p', upload_parent_commit]
         commit_env = copy.copy(self._env)
         commit_env.update(self.get_commit_environment(tree_hash, spi, patch_overrides))
-        try:
-            _, commit_msg_file = tempfile.mkstemp()
-            with open(commit_msg_file, "wb") as fp:
-                fp.write(msg)
-            commit_tree += ['-F', commit_msg_file]
+        with tempfile.NamedTemporaryFile() as fp:
+            fp.write(msg)
+            fp.flush()
+            commit_tree += ['-F', fp.name]
             cp = run(commit_tree, env=commit_env)
-        finally:
-            if commit_msg_file:
-                os.unlink(commit_msg_file)
 
         commit_hash = decode_binary(cp.stdout).strip()
         self.update_head_to_commit(spi.head_name, commit_hash)
Download as text