Skip to content
Myr

Add check for WIN in _tempfilepager finally block to prevent file in use error on windows

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jay Crotts · committed by David Lord · parent 09b9d61 · Browse files · 1 file+3 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−1 removed

  • other:+3 added−1 removed

1 file+3 added−1 removed

modified:src/click/_termui_impl.py+3 added-1 removed
424 unmodified lines
425) -> None:426 """Page through text by invoking a program on a temporary file."""427 import tempfile428429 _, filename = tempfile.mkstemp()429 fd, filename = tempfile.mkstemp()430 # TODO: This never terminates if the passed generator never terminates.431 text = "".join(generator)432 if not color:433 text = strip_ansi(text)
2 unmodified lines
436 f.write(text.encode(encoding))437 try:438 os.system(f'{cmd} "{filename}"')439 finally:440 if WIN:441 os.close(fd)442 os.unlink(filename)443444445def _nullpager(
274 unmodified lines