summaryrefslogtreecommitdiff
path: root/Cython/Debugger
diff options
context:
space:
mode:
authorJeroen Demeyer <jdemeyer@cage.ugent.be>2018-02-08 17:49:42 +0100
committerJeroen Demeyer <jdemeyer@cage.ugent.be>2018-02-09 10:40:46 +0100
commitbb4f0a9c656b52579ca7fabcc43fd72804e0e318 (patch)
treec50051b138998df1be3556e3c50925671db5c7a8 /Cython/Debugger
parent5af807ff54d9aa4799fbcff555f5da75f7cc51d5 (diff)
downloadcython-bb4f0a9c656b52579ca7fabcc43fd72804e0e318.tar.gz
Use NamedTemporaryFile instead of mkstemp
Diffstat (limited to 'Cython/Debugger')
-rw-r--r--Cython/Debugger/libpython.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/Cython/Debugger/libpython.py b/Cython/Debugger/libpython.py
index 9e94168a0..dc3e44a47 100644
--- a/Cython/Debugger/libpython.py
+++ b/Cython/Debugger/libpython.py
@@ -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")