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