##// 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"""
228 save_findsource = inspect.findsource
229 inspect.findsource = findsource
230 try:
231 yield
232 finally:
233 inspect.findsource = save_findsource
234
235 224 def with_patch_inspect(f):
236 225 """decorator for monkeypatching inspect.findsource"""
237 226 def wrapped(*args, **kwargs):
238 with patch_inspect():
227 save_findsource = inspect.findsource
228 inspect.findsource = findsource
229 try:
239 230 return f(*args, **kwargs)
231 finally:
232 inspect.findsource = save_findsource
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