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