Show More
@@ -108,6 +108,14 b' class EmbeddedMagics(Magics):' | |||
|
108 | 108 | self.shell.ask_exit() |
|
109 | 109 | |
|
110 | 110 | |
|
111 | class _Sentinel: | |
|
112 | def __init__(self, repr): | |
|
113 | assert isinstance(repr, str) | |
|
114 | self.repr = repr | |
|
115 | ||
|
116 | def __repr__(self): | |
|
117 | return repr | |
|
118 | ||
|
111 | 119 | |
|
112 | 120 | class InteractiveShellEmbed(TerminalInteractiveShell): |
|
113 | 121 | |
@@ -148,9 +156,9 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||
|
148 | 156 | self._call_location_id) |
|
149 | 157 | |
|
150 | 158 | def __init__(self, **kw): |
|
151 | if kw.get('user_global_ns', None) is not None: | |
|
152 | raise DeprecationWarning( | |
|
153 |
|
|
|
159 | assert ( | |
|
160 | "user_global_ns" not in kw | |
|
161 | ), "Key word argument `user_global_ns` has been replaced by `user_module` since IPython 4.0." | |
|
154 | 162 | |
|
155 | 163 | clid = kw.pop('_init_location_id', None) |
|
156 | 164 | if not clid: |
@@ -176,8 +184,16 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||
|
176 | 184 | super(InteractiveShellEmbed, self).init_magics() |
|
177 | 185 | self.register_magics(EmbeddedMagics) |
|
178 | 186 | |
|
179 | def __call__(self, header='', local_ns=None, module=None, dummy=None, | |
|
180 | stack_depth=1, global_ns=None, compile_flags=None, **kw): | |
|
187 | def __call__( | |
|
188 | self, | |
|
189 | header="", | |
|
190 | local_ns=None, | |
|
191 | module=None, | |
|
192 | dummy=None, | |
|
193 | stack_depth=1, | |
|
194 | compile_flags=None, | |
|
195 | **kw | |
|
196 | ): | |
|
181 | 197 | """Activate the interactive interpreter. |
|
182 | 198 | |
|
183 | 199 | __call__(self,header='',local_ns=None,module=None,dummy=None) -> Start |
@@ -227,8 +243,9 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||
|
227 | 243 | |
|
228 | 244 | # Call the embedding code with a stack depth of 1 so it can skip over |
|
229 | 245 | # our call and get the original caller's namespaces. |
|
230 | self.mainloop(local_ns, module, stack_depth=stack_depth, | |
|
231 |
|
|
|
246 | self.mainloop( | |
|
247 | local_ns, module, stack_depth=stack_depth, compile_flags=compile_flags | |
|
248 | ) | |
|
232 | 249 | |
|
233 | 250 | self.banner2 = self.old_banner2 |
|
234 | 251 | |
@@ -238,14 +255,19 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||
|
238 | 255 | if self.should_raise: |
|
239 | 256 | raise KillEmbedded('Embedded IPython raising error, as user requested.') |
|
240 | 257 | |
|
241 | ||
|
242 | def mainloop(self, local_ns=None, module=None, stack_depth=0, | |
|
243 | display_banner=None, global_ns=None, compile_flags=None): | |
|
258 | def mainloop( | |
|
259 | self, | |
|
260 | local_ns=None, | |
|
261 | module=None, | |
|
262 | stack_depth=0, | |
|
263 | compile_flags=None, | |
|
264 | ): | |
|
244 | 265 | """Embeds IPython into a running python program. |
|
245 | 266 | |
|
246 | 267 | Parameters |
|
247 | 268 | ---------- |
|
248 | 269 | |
|
270 | ||
|
249 | 271 | local_ns, module |
|
250 | 272 | Working local namespace (a dict) and module (a module or similar |
|
251 | 273 | object). If given as None, they are automatically taken from the scope |
@@ -266,12 +288,6 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||
|
266 | 288 | |
|
267 | 289 | """ |
|
268 | 290 | |
|
269 | if (global_ns is not None) and (module is None): | |
|
270 | raise DeprecationWarning("'global_ns' keyword argument is deprecated, and has been removed in IPython 5.0 use `module` keyword argument instead.") | |
|
271 | ||
|
272 | if (display_banner is not None): | |
|
273 | warnings.warn("The display_banner parameter is deprecated since IPython 4.0", DeprecationWarning) | |
|
274 | ||
|
275 | 291 | # Get locals and globals from caller |
|
276 | 292 | if ((local_ns is None or module is None or compile_flags is None) |
|
277 | 293 | and self.default_user_namespaces): |
General Comments 0
You need to be logged in to leave comments.
Login now