From 6ffade0c350d728440782395172bbe57343a0adb 2011-04-26 15:19:06 From: Evan Patterson Date: 2011-04-26 15:19:06 Subject: [PATCH] Fix Windows-specific bug in path handling for Qt console. --- diff --git a/IPython/frontend/qt/console/frontend_widget.py b/IPython/frontend/qt/console/frontend_widget.py index affdd22..94e506a 100644 --- a/IPython/frontend/qt/console/frontend_widget.py +++ b/IPython/frontend/qt/console/frontend_widget.py @@ -435,7 +435,7 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): """ Attempts to execute file with 'path'. If 'hidden', no output is shown. """ - self.execute('execfile("%s")' % path, hidden=hidden) + self.execute('execfile(%r)' % path, hidden=hidden) def interrupt_kernel(self): """ Attempts to interrupt the running kernel. diff --git a/IPython/frontend/qt/console/ipython_widget.py b/IPython/frontend/qt/console/ipython_widget.py index 2e35e9b..291aaaf 100644 --- a/IPython/frontend/qt/console/ipython_widget.py +++ b/IPython/frontend/qt/console/ipython_widget.py @@ -8,8 +8,10 @@ # Standard library imports from collections import namedtuple +import os.path import re from subprocess import Popen +import sys from textwrap import dedent # System library imports @@ -233,6 +235,10 @@ class IPythonWidget(FrontendWidget): def execute_file(self, path, hidden=False): """ Reimplemented to use the 'run' magic. """ + # Use forward slashes on Windows to avoid escaping each separator. + if sys.platform == 'win32': + path = os.path.normpath(path).replace('\\', '/') + self.execute('%%run %s' % path, hidden=hidden) #---------------------------------------------------------------------------