Mercurial > hg
diff hgext/infinitepush/store.py @ 38166:cc9aa88792fe
py3: wrap tempfile.NamedTemporaryFile() to return bytes fp.name
Unlike its name, tempfile.NamedTemporaryFile is not a class, so I renamed
the pycompat version to look like a plain function.
Since temp.name uses in the infinitepush extension aren't bytes-safe, this
patch leaves them unmodified. Another weird thing is tempfile.mktemp(),
which does not accept bytes suffix nor prefix. Sigh.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 26 May 2018 12:38:07 +0900 |
parents | 968ac00c4017 |
children | c31ce080eb75 |
line wrap: on
line diff
--- a/hgext/infinitepush/store.py Sat May 26 12:20:36 2018 +0900 +++ b/hgext/infinitepush/store.py Sat May 26 12:38:07 2018 +0900 @@ -120,6 +120,8 @@ def write(self, data): # 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: temp.write(data) temp.flush() @@ -142,6 +144,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: formatted_args = [arg.format(filename=temp.name, handle=handle) for arg in self.get_args]