##// END OF EJS Templates
Backport PR #6195: Close handle on new temporary files before returning filename...
MinRK -
Show More
@@ -3036,6 +3036,7 b' class InteractiveShell(SingletonConfigurable):'
3036 3036 self.tempdirs.append(dirname)
3037 3037
3038 3038 handle, filename = tempfile.mkstemp('.py', prefix, dir=dirname)
3039 os.close(handle) # On Windows, there can only be one open handle on a file
3039 3040 self.tempfiles.append(filename)
3040 3041
3041 3042 if data:
@@ -417,6 +417,15 b' class InteractiveShellTestCase(unittest.TestCase):'
417 417 ip.run_cell("d = 1/2", shell_futures=True)
418 418 self.assertEqual(ip.user_ns['d'], 0)
419 419
420 def test_mktempfile(self):
421 filename = ip.mktempfile()
422 # Check that we can open the file again on Windows
423 with open(filename, 'w') as f:
424 f.write('abc')
425
426 filename = ip.mktempfile(data='blah')
427 with open(filename, 'r') as f:
428 self.assertEqual(f.read(), 'blah')
420 429
421 430 class TestSafeExecfileNonAsciiPath(unittest.TestCase):
422 431
General Comments 0
You need to be logged in to leave comments. Login now