Commit bb4f0a9c authored by Jeroen Demeyer's avatar Jeroen Demeyer

Use NamedTemporaryFile instead of mkstemp

parent 5af807ff
......@@ -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