diff --git a/IPython/terminal/embed.py b/IPython/terminal/embed.py index d2cbe88..4763598 100644 --- a/IPython/terminal/embed.py +++ b/IPython/terminal/embed.py @@ -108,6 +108,14 @@ class EmbeddedMagics(Magics): self.shell.ask_exit() +class _Sentinel: + def __init__(self, repr): + assert isinstance(repr, str) + self.repr = repr + + def __repr__(self): + return repr + class InteractiveShellEmbed(TerminalInteractiveShell): @@ -148,9 +156,9 @@ class InteractiveShellEmbed(TerminalInteractiveShell): self._call_location_id) def __init__(self, **kw): - if kw.get('user_global_ns', None) is not None: - raise DeprecationWarning( - "Key word argument `user_global_ns` has been replaced by `user_module` since IPython 4.0.") + assert ( + "user_global_ns" not in kw + ), "Key word argument `user_global_ns` has been replaced by `user_module` since IPython 4.0." clid = kw.pop('_init_location_id', None) if not clid: @@ -176,8 +184,16 @@ class InteractiveShellEmbed(TerminalInteractiveShell): super(InteractiveShellEmbed, self).init_magics() self.register_magics(EmbeddedMagics) - def __call__(self, header='', local_ns=None, module=None, dummy=None, - stack_depth=1, global_ns=None, compile_flags=None, **kw): + def __call__( + self, + header="", + local_ns=None, + module=None, + dummy=None, + stack_depth=1, + compile_flags=None, + **kw + ): """Activate the interactive interpreter. __call__(self,header='',local_ns=None,module=None,dummy=None) -> Start @@ -227,8 +243,9 @@ class InteractiveShellEmbed(TerminalInteractiveShell): # Call the embedding code with a stack depth of 1 so it can skip over # our call and get the original caller's namespaces. - self.mainloop(local_ns, module, stack_depth=stack_depth, - global_ns=global_ns, compile_flags=compile_flags) + self.mainloop( + local_ns, module, stack_depth=stack_depth, compile_flags=compile_flags + ) self.banner2 = self.old_banner2 @@ -238,14 +255,19 @@ class InteractiveShellEmbed(TerminalInteractiveShell): if self.should_raise: raise KillEmbedded('Embedded IPython raising error, as user requested.') - - def mainloop(self, local_ns=None, module=None, stack_depth=0, - display_banner=None, global_ns=None, compile_flags=None): + def mainloop( + self, + local_ns=None, + module=None, + stack_depth=0, + compile_flags=None, + ): """Embeds IPython into a running python program. Parameters ---------- + local_ns, module Working local namespace (a dict) and module (a module or similar object). If given as None, they are automatically taken from the scope @@ -266,12 +288,6 @@ class InteractiveShellEmbed(TerminalInteractiveShell): """ - if (global_ns is not None) and (module is None): - raise DeprecationWarning("'global_ns' keyword argument is deprecated, and has been removed in IPython 5.0 use `module` keyword argument instead.") - - if (display_banner is not None): - warnings.warn("The display_banner parameter is deprecated since IPython 4.0", DeprecationWarning) - # Get locals and globals from caller if ((local_ns is None or module is None or compile_flags is None) and self.default_user_namespaces):