##// END OF EJS Templates
Simplify code with a context manager
Thomas Kluyver -
Show More
@@ -344,13 +344,10 b' class TerminalInteractiveShell(InteractiveShell):'
344 self.showtraceback()
344 self.showtraceback()
345 else:
345 else:
346 try:
346 try:
347 f = open(err.filename)
347 with open(err.filename) as f:
348 try:
349 # This should be inside a display_trap block and I
348 # This should be inside a display_trap block and I
350 # think it is.
349 # think it is.
351 sys.displayhook(f.read())
350 sys.displayhook(f.read())
352 finally:
353 f.close()
354 except:
351 except:
355 self.showtraceback()
352 self.showtraceback()
356
353
General Comments 0
You need to be logged in to leave comments. Login now