infinitepush: replace `NamedTemporaryFile` with `pycompat.namedtempfile` stable
authorConnor Sheehan <sheehan@mozilla.com>
Wed, 22 Apr 2020 17:59:17 -0400
branchstable
changeset 45186 a52bf967e90a
parent 45185 a17454a189d1
child 45187 e285655c37c5
infinitepush: replace `NamedTemporaryFile` with `pycompat.namedtempfile` Fixes a Python 3 compat error when using the external bundle store. Differential Revision: https://phab.mercurial-scm.org/D8780
hgext/infinitepush/store.py
--- a/hgext/infinitepush/store.py	Mon Jul 20 20:31:24 2020 +0900
+++ b/hgext/infinitepush/store.py	Wed Apr 22 17:59:17 2020 -0400
@@ -20,8 +20,6 @@
     procutil,
 )
 
-NamedTemporaryFile = tempfile.NamedTemporaryFile
-
 
 class BundleWriteException(Exception):
     pass
@@ -142,7 +140,7 @@
         # closing it
         # TODO: rewrite without str.format() and replace NamedTemporaryFile()
         # with pycompat.namedtempfile()
-        with NamedTemporaryFile() as temp:
+        with pycompat.namedtempfile() as temp:
             temp.write(data)
             temp.flush()
             temp.seek(0)
@@ -168,9 +166,8 @@
     def read(self, handle):
         # Won't work on windows because you can't open file second time without
         # closing it
-        # TODO: rewrite without str.format() and replace NamedTemporaryFile()
-        # with pycompat.namedtempfile()
-        with NamedTemporaryFile() as temp:
+        # TODO: rewrite without str.format()
+        with pycompat.namedtempfile() as temp:
             formatted_args = [
                 arg.format(filename=temp.name, handle=handle)
                 for arg in self.get_args