[Piglit] [PATCH 17/20] framework: encode arguments to subprocess for python2 on windows
Dylan Baker
dylan at pnwbakers.com
Wed Jun 1 23:50:24 UTC 2016
Subprocess from Python 2 on windows is an interesting beast. The way
it's implemented is a little strange, and passing environment variables
as unicode breaks things. It works fine on POSIX, however. So for
windows convert to binary.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/test/base.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/framework/test/base.py b/framework/test/base.py
index ff129ed..0d5fc1e 100644
--- a/framework/test/base.py
+++ b/framework/test/base.py
@@ -302,12 +302,16 @@ class Test(object):
# Piglit considers environment variables set in all.py (3) to be test
# requirements.
#
- fullenv = dict()
- for key, value in itertools.chain(six.iteritems(os.environ),
- six.iteritems(options.OPTIONS.env),
- six.iteritems(self.env)):
- fullenv[key] = str(value)
-
+ # passing this as unicode is basically broken in python2 on windows, it
+ # must be passed a bytes.
+ if six.PY2 and sys.platform.startswith('win32'):
+ f = six.binary_type
+ else:
+ f = six.text_type
+ _base = itertools.chain(six.iteritems(os.environ),
+ six.iteritems(options.OPTIONS.env),
+ six.iteritems(self.env))
+ fullenv = {f(k): f(v) for k, v in _base}
try:
proc = subprocess.Popen(self.command,
--
2.8.3
More information about the Piglit
mailing list