Skip to content

Commit cf8c513

Browse files
committed
Fix python3 jupyter problem with EnvironmentBlock null char
1 parent 5521b0e commit cf8c513

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

powershell_kernel/install.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def install_my_kernel_spec(user=True, prefix=None, powershell_command=None):
4040
else:
4141
# python 2 cannot use env to pass values to the kernel
4242
# https://github.com/vors/jupyter-powershell/issues/7
43+
# TODO(python2): find a way to pass it
4344
if powershell_command is not None:
4445
print('Ignoring powershell_command on python2, jupyter will use default powershell_command=%r' % powershell_command)
4546

powershell_kernel/kernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, **kwargs):
4141

4242
# powershell_command env variable is set by the kernel to allow both powershell and pwsh
4343
# but on python2 we cannot pass it thru env variable, see https://github.com/vors/jupyter-powershell/issues/7
44-
# TODO: can we pass it somehow differently and still provide user-picked value on python2?
44+
# TODO(python2): can we pass it somehow differently and still provide user-picked value on python2?
4545
try:
4646
powershell_command = environ['powershell_command']
4747
except:

powershell_kernel/killableprocess/winprocess.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from ctypes import c_void_p, POINTER, sizeof, Structure, windll, WinError, WINFUNCTYPE
3838
from ctypes.wintypes import BOOL, BYTE, DWORD, HANDLE, LPCWSTR, LPWSTR, UINT, WORD
3939
from .qijo import QueryInformationJobObject
40+
from sys import version_info
4041

4142
LPVOID = c_void_p
4243
LPBYTE = POINTER(BYTE)
@@ -138,10 +139,15 @@ def __init__(self, dict):
138139
if not dict:
139140
self._as_parameter_ = None
140141
else:
141-
values = ["%s=%s" % (key, value)
142-
for (key, value) in dict.items()]
143-
values.append("")
144-
self._as_parameter_ = LPCWSTR("\0".join(values))
142+
if version_info >= (3, 0):
143+
# on python3 LPCWSTR("\0") errors with 'ValueError: embedded null character'
144+
# TODO(python3): find a proper fix for that
145+
self._as_parameter_ = None
146+
else:
147+
values = ["%s=%s" % (key, value)
148+
for (key, value) in dict.items()]
149+
values.append("")
150+
self._as_parameter_ = LPCWSTR("\0".join(values))
145151

146152
# CreateProcess()
147153

0 commit comments

Comments
 (0)