From 742c8eb946efbe119f4a233bb912447f6501d412 2014-01-22 23:13:39 From: MinRK Date: 2014-01-22 23:13:39 Subject: [PATCH] Popen doesn't support unicode args on Windows Python 2 --- diff --git a/IPython/kernel/launcher.py b/IPython/kernel/launcher.py index b638263..dcf7fe1 100644 --- a/IPython/kernel/launcher.py +++ b/IPython/kernel/launcher.py @@ -21,6 +21,7 @@ import os import sys from subprocess import Popen, PIPE +from IPython.utils.encoding import getdefaultencoding from IPython.utils.py3compat import cast_bytes_py2 #----------------------------------------------------------------------------- @@ -188,12 +189,14 @@ def launch_kernel(cmd, stdin=None, stdout=None, stderr=None, _stderr = PIPE if stderr is None else stderr else: _stdout, _stderr = stdout, stderr - + + encoding = getdefaultencoding(prefer_stream=False) + # Spawn a kernel. if sys.platform == 'win32': - + # Popen on Python 2 on Windows cannot handle unicode args or cwd + cmd = [ cast_bytes_py2(c, encoding) for c in cmd ] if cwd: - # Popen on Python 2 on Windows cannot handle unicode cwd. cwd = cast_bytes_py2(cwd, sys.getfilesystemencoding() or 'ascii') from IPython.kernel.zmq.parentpoller import ParentPollerWindows