diff --git a/testing/mozbase/mozprocess/mozprocess/processhandler.py b/testing/mozbase/mozprocess/mozprocess/processhandler.py index 77ac14c74857..ee2a6eab50a6 100644 --- a/testing/mozbase/mozprocess/mozprocess/processhandler.py +++ b/testing/mozbase/mozprocess/mozprocess/processhandler.py @@ -721,9 +721,7 @@ falling back to not using job objects for managing child processes""", file=sys. self.keywordargs = kwargs self.read_buffer = '' - # XXX Bug 1585702 - Setting env is broken on Windows + Python 3. In the - # meantime let's at least make sure we don't set it in the default case. - if env is None and not (six.PY3 and isWin): + if env is None: env = os.environ.copy() self.env = env diff --git a/testing/mozbase/mozprocess/mozprocess/winprocess.py b/testing/mozbase/mozprocess/mozprocess/winprocess.py index 6b965a318b1e..446578ca0b4b 100644 --- a/testing/mozbase/mozprocess/mozprocess/winprocess.py +++ b/testing/mozbase/mozprocess/mozprocess/winprocess.py @@ -38,7 +38,18 @@ from __future__ import absolute_import, unicode_literals, print_function import subprocess import sys -from ctypes import c_void_p, POINTER, sizeof, Structure, windll, WinError, WINFUNCTYPE, c_ulong +from ctypes import ( + cast, + create_unicode_buffer, + c_ulong, + c_void_p, + POINTER, + sizeof, + Structure, + windll, + WinError, + WINFUNCTYPE, +) from ctypes.wintypes import BOOL, BYTE, DWORD, HANDLE, LPCWSTR, LPWSTR, UINT, WORD from .qijo import QueryInformationJobObject @@ -163,8 +174,13 @@ class EnvironmentBlock: if isinstance(v, bytes): v = v.decode(fs_encoding, 'replace') values.append("{}={}".format(k, v)) - values.append("") - self._as_parameter_ = LPCWSTR("\0".join(values)) + + # The lpEnvironment parameter of the 'CreateProcess' function expects a series + # of null terminated strings followed by a final null terminator. We write this + # value to a buffer and then cast it to LPCWSTR to avoid a Python ctypes bug + # that probihits embedded null characters (https://bugs.python.org/issue32745). + values = create_unicode_buffer("\0".join(values) + "\0") + self._as_parameter_ = cast(values, LPCWSTR) # Error Messages we need to watch for go here diff --git a/testing/mozbase/mozprocess/tests/manifest.ini b/testing/mozbase/mozprocess/tests/manifest.ini index 119910f029ac..ec1dcf2cff6a 100644 --- a/testing/mozbase/mozprocess/tests/manifest.ini +++ b/testing/mozbase/mozprocess/tests/manifest.ini @@ -1,7 +1,5 @@ [DEFAULT] subsuite = mozbase -# Python bug https://bugs.python.org/issue32745 -skip-if = python == 3 && os == "win" # Bug 1428713 for more info [test_detached.py] skip-if = os == "win" # Bug 1493796 [test_kill.py]