diff options
-rwxr-xr-x | lib-python/2.7/pydoc.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib-python/2.7/pydoc.py b/lib-python/2.7/pydoc.py index 87b7c2c0d4..5bdf8ebb62 100755 --- a/lib-python/2.7/pydoc.py +++ b/lib-python/2.7/pydoc.py @@ -1425,15 +1425,16 @@ def pipepager(text, cmd): def tempfilepager(text, cmd): """Page through text by invoking a program on a temporary file.""" + import shutil import tempfile - filename = tempfile.mktemp() - file = open(filename, 'w') - file.write(_encode(text)) - file.close() + tempdir = tempfile.mkdtemp() try: + filename = os.path.join(tempdir, 'pydoc.out') + with open(filename, 'w') as file: + file.write(_encode(text)) os.system(cmd + ' "' + filename + '"') finally: - os.unlink(filename) + shutil.rmtree(tempdir) def ttypager(text): """Page through text on a text terminal.""" |