Scrapy, a fast high-level web crawling & scraping framework for Python.
IPython refuses to update the namespace. fix #396
Daniel Grañaaa6fb7daaacd
diff --git a/scrapy/utils/console.py b/scrapy/utils/console.pyindex 1c4449b85..25782d512 100644--- a/scrapy/utils/console.py+++ b/scrapy/utils/console.py@@ -1,21 +1,25 @@-def start_python_console(namespace=None, noipython=False):+def start_python_console(namespace=None, noipython=False, banner=''):"""Start Python console binded to the given namespace. If IPython isavailable, an IPython console will be started instead, unless `noipython`is True. Also, tab completion will be used on Unix systems."""if namespace is None:namespace = {}+try:try: # use IPython if availableif noipython:- raise ImportError- import IPython+ raise ImportError()+try:- IPython.embed(user_ns=namespace)- except AttributeError:- shell = IPython.Shell.IPShellEmbed(argv=[], user_ns=namespace)- shell()+ from IPython.frontend.terminal.embed import InteractiveShellEmbed+ sh = InteractiveShellEmbed(banner1=banner)+ except ImportError:+ from IPython.Shell import IPShellEmbed+ sh = IPShellEmbed(banner=banner)++ sh(global_ns={}, local_ns=namespace)except ImportError:import codetry: # readline module is only available on unix systems@@ -25,6 +29,6 @@ def start_python_console(namespace=None, noipython=False):else:import rlcompleterreadline.parse_and_bind("tab:complete")- code.interact(banner='', local=namespace)+ code.interact(banner=banner, local=namespace)except SystemExit: # raised when using exit() in python code.interactpass