##// END OF EJS Templates
get rid of redundant context manager
MinRK -
Show More
@@ -83,7 +83,6 b' Inheritance diagram:'
83 from __future__ import unicode_literals
83 from __future__ import unicode_literals
84 from __future__ import print_function
84 from __future__ import print_function
85
85
86 from contextlib import contextmanager
87 import inspect
86 import inspect
88 import keyword
87 import keyword
89 import linecache
88 import linecache
@@ -222,21 +221,15 b' def findsource(object):'
222 raise IOError('could not find code object')
221 raise IOError('could not find code object')
223
222
224 # Monkeypatch inspect to apply our bugfix.
223 # Monkeypatch inspect to apply our bugfix.
225 @contextmanager
224 def with_patch_inspect(f):
226 def patch_inspect():
225 """decorator for monkeypatching inspect.findsource"""
227 """context manager for monkeypatching inspect.findsource"""
226 def wrapped(*args, **kwargs):
228 save_findsource = inspect.findsource
227 save_findsource = inspect.findsource
229 inspect.findsource = findsource
228 inspect.findsource = findsource
230 try:
229 try:
231 yield
230 return f(*args, **kwargs)
232 finally:
231 finally:
233 inspect.findsource = save_findsource
232 inspect.findsource = save_findsource
234
235 def with_patch_inspect(f):
236 """decorator for monkeypatching inspect.findsource"""
237 def wrapped(*args, **kwargs):
238 with patch_inspect():
239 return f(*args, **kwargs)
240 return wrapped
233 return wrapped
241
234
242 def fix_frame_records_filenames(records):
235 def fix_frame_records_filenames(records):
General Comments 0
You need to be logged in to leave comments. Login now