##// END OF EJS Templates
Move Extraction of local scope to a method...
Quentin Peter -
Show More
@@ -2322,11 +2322,21 b' class InteractiveShell(SingletonConfigurable):'
2322 kwargs = {}
2322 kwargs = {}
2323 # Grab local namespace if we need it:
2323 # Grab local namespace if we need it:
2324 if getattr(fn, "needs_local_scope", False):
2324 if getattr(fn, "needs_local_scope", False):
2325 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2325 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2326 with self.builtin_trap:
2326 with self.builtin_trap:
2327 result = fn(*args, **kwargs)
2327 result = fn(*args, **kwargs)
2328 return result
2328 return result
2329
2329
2330 def get_local_scope(self, stack_depth):
2331 """Get local scope at given stack depth.
2332
2333 Parameters
2334 ----------
2335 stack_depth : int
2336 Depth relative to calling frame
2337 """
2338 return sys._getframe(stack_depth + 1).f_locals
2339
2330 def run_cell_magic(self, magic_name, line, cell):
2340 def run_cell_magic(self, magic_name, line, cell):
2331 """Execute the given cell magic.
2341 """Execute the given cell magic.
2332
2342
General Comments 0
You need to be logged in to leave comments. Login now