Commit aff88c52 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2095 from jdemeyer/atexit_close

Use NamedTemporaryFile instead of mkstemp
parents 223ab47f bb4f0a9c
......@@ -1941,7 +1941,6 @@ PyLocals()
##################################################################
import re
import atexit
import warnings
import tempfile
import textwrap
......@@ -2023,14 +2022,13 @@ class _LoggingState(object):
"""
def __init__(self):
self.fd, self.filename = tempfile.mkstemp()
self.file = os.fdopen(self.fd, 'r+')
f = tempfile.NamedTemporaryFile('r+')
self.file = f
self.filename = f.name
self.fd = f.fileno()
_execute("set logging file %s" % self.filename)
self.file_position_stack = []
atexit.register(os.close, self.fd)
atexit.register(os.remove, self.filename)
def __enter__(self):
if not self.file_position_stack:
_execute("set logging redirect on")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment