##// END OF EJS Templates
Allow run_line_magic to be called from scripts...
Thomas Kluyver -
Show More
@@ -3102,7 +3102,15 b' class InteractiveShell(SingletonConfigurable):'
3102 namespace.
3102 namespace.
3103 """
3103 """
3104 ns = self.user_ns.copy()
3104 ns = self.user_ns.copy()
3105 ns.update(sys._getframe(depth+1).f_locals)
3105 try:
3106 frame = sys._getframe(depth+1)
3107 except ValueError:
3108 # This is thrown if there aren't that many frames on the stack,
3109 # e.g. if a script called run_line_magic() directly.
3110 pass
3111 else:
3112 ns.update(frame.f_locals)
3113
3106 try:
3114 try:
3107 # We have to use .vformat() here, because 'self' is a valid and common
3115 # We have to use .vformat() here, because 'self' is a valid and common
3108 # name, and expanding **ns for .format() would make it collide with
3116 # name, and expanding **ns for .format() would make it collide with
General Comments 0
You need to be logged in to leave comments. Login now