Mercurial > hg
comparison mercurial/pycompat.py @ 46570:7a29d9002250 stable
pycompat: fix a bytes vs str issue in `unnamedtempfile()`
This seems trivially correct, though the only two uses I found both took this
path. So I'm guessing we're missing test coverage.
Differential Revision: https://phab.mercurial-scm.org/D10129
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 08 Mar 2021 12:28:53 -0500 |
parents | e3d595b7fbaa |
children | 2b76255a4f74 |
comparison
equal
deleted
inserted
replaced
46550:a9887f9e87aa | 46570:7a29d9002250 |
---|---|
508 | 508 |
509 # TemporaryFile does not support an "encoding=" argument on python2. | 509 # TemporaryFile does not support an "encoding=" argument on python2. |
510 # This wrapper file are always open in byte mode. | 510 # This wrapper file are always open in byte mode. |
511 def unnamedtempfile(mode=None, *args, **kwargs): | 511 def unnamedtempfile(mode=None, *args, **kwargs): |
512 if mode is None: | 512 if mode is None: |
513 mode = b'w+b' | 513 mode = 'w+b' |
514 else: | 514 else: |
515 mode = sysstr(mode) | 515 mode = sysstr(mode) |
516 assert 'b' in mode | 516 assert 'b' in mode |
517 return tempfile.TemporaryFile(mode, *args, **kwargs) | 517 return tempfile.TemporaryFile(mode, *args, **kwargs) |
518 | 518 |