Mercurial > public > mercurial-scm > hg
comparison mercurial/utils/procutil.py @ 52582:1b9b6b4aa929
procutil: don't leak a file descriptor when I/O fails filtering through files
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 17 Dec 2024 01:45:29 -0500 |
parents | 07a5a249faf8 |
children | 24ee91ba9aa8 |
comparison
equal
deleted
inserted
replaced
52581:cc918741a22a | 52582:1b9b6b4aa929 |
---|---|
326 with the strings INFILE and OUTFILE replaced by the real names of | 326 with the strings INFILE and OUTFILE replaced by the real names of |
327 the temporary files generated.""" | 327 the temporary files generated.""" |
328 inname, outname = None, None | 328 inname, outname = None, None |
329 try: | 329 try: |
330 infd, inname = pycompat.mkstemp(prefix=b'hg-filter-in-') | 330 infd, inname = pycompat.mkstemp(prefix=b'hg-filter-in-') |
331 fp = os.fdopen(infd, 'wb') | 331 |
332 fp.write(s) | 332 with os.fdopen(infd, 'wb') as fp: |
333 fp.close() | 333 fp.write(s) |
334 | |
334 outfd, outname = pycompat.mkstemp(prefix=b'hg-filter-out-') | 335 outfd, outname = pycompat.mkstemp(prefix=b'hg-filter-out-') |
335 os.close(outfd) | 336 os.close(outfd) |
336 cmd = cmd.replace(b'INFILE', inname) | 337 cmd = cmd.replace(b'INFILE', inname) |
337 cmd = cmd.replace(b'OUTFILE', outname) | 338 cmd = cmd.replace(b'OUTFILE', outname) |
338 code = system(cmd) | 339 code = system(cmd) |