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