##// END OF EJS Templates
Drop nested() function for context managers
Thomas Kluyver -
Show More
@@ -25,11 +25,6 b' import base64'
25 25
26 26 from Queue import Empty
27 27
28 try:
29 from contextlib import nested
30 except:
31 from IPython.utils.nested_context import nested
32
33 28 from IPython.core import page
34 29 from IPython.utils.warn import warn, error
35 30 from IPython.utils import io
@@ -303,8 +298,8 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
303 298 raw = base64.decodestring(data[mime].encode('ascii'))
304 299 imageformat = self._imagemime[mime]
305 300 filename = 'tmp.{0}'.format(imageformat)
306 with nested(NamedFileInTemporaryDirectory(filename),
307 open(os.devnull, 'w')) as (f, devnull):
301 with NamedFileInTemporaryDirectory(filename) as f, \
302 open(os.devnull, 'w') as devnull:
308 303 f.write(raw)
309 304 f.flush()
310 305 fmt = dict(file=f.name, format=imageformat)
@@ -27,13 +27,6 b' from __future__ import with_statement'
27 27 import sys
28 28 import warnings
29 29
30 # We need to use nested to support python 2.6, once we move to >=2.7, we can
31 # use the with keyword's new builtin support for nested managers
32 try:
33 from contextlib import nested
34 except:
35 from IPython.utils.nested_context import nested
36
37 30 from IPython.core import ultratb, compilerop
38 31 from IPython.core.magic import Magics, magics_class, line_magic
39 32 from IPython.terminal.interactiveshell import TerminalInteractiveShell
@@ -251,7 +244,7 b' class InteractiveShellEmbed(TerminalInteractiveShell):'
251 244 # actually completes using the frame's locals/globals
252 245 self.set_completer_frame()
253 246
254 with nested(self.builtin_trap, self.display_trap):
247 with self.builtin_trap, self.display_trap:
255 248 self.interact(display_banner=display_banner)
256 249
257 250 # now, purge out the local namespace of IPython's hidden variables.
@@ -19,13 +19,6 b' import bdb'
19 19 import os
20 20 import sys
21 21
22 # We need to use nested to support python 2.6, once we move to >=2.7, we can
23 # use the with keyword's new builtin support for nested managers
24 try:
25 from contextlib import nested
26 except:
27 from IPython.utils.nested_context import nested
28
29 22 from IPython.core.error import TryNext, UsageError
30 23 from IPython.core.usage import interactive_usage, default_banner
31 24 from IPython.core.inputsplitter import IPythonInputSplitter
@@ -429,7 +422,7 b' class TerminalInteractiveShell(InteractiveShell):'
429 422 internally created default banner.
430 423 """
431 424
432 with nested(self.builtin_trap, self.display_trap):
425 with self.builtin_trap, self.display_trap:
433 426
434 427 while 1:
435 428 try:
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now