I just learned I was supposed to send this :) Reviewed-by: Mathieu Bridon <boche...@daitauha.fr>
On Fri, 2018-08-17 at 11:07 -0700, Dylan Baker wrote: > v2: - explicitly decode the output of subprocesses > - handle bytes and string types consistently rather than relying > on > python 2's coercion for bytes and ignoring them in python 3 > v3: - explicitly set encode as well as decode > - python 2.7 and 3.x `bytes` instead of defining an alias > --- > src/compiler/glsl/tests/lower_jump_cases.py | 2 +- > src/compiler/glsl/tests/optimization_test.py | 6 ++++-- > src/compiler/glsl/tests/sexps.py | 11 +++++++++-- > 3 files changed, 14 insertions(+), 5 deletions(-) > > diff --git a/src/compiler/glsl/tests/lower_jump_cases.py > b/src/compiler/glsl/tests/lower_jump_cases.py > index b50ab734798..1977f3a9b4f 100644 > --- a/src/compiler/glsl/tests/lower_jump_cases.py > +++ b/src/compiler/glsl/tests/lower_jump_cases.py > @@ -54,7 +54,7 @@ def make_test_case(f_name, ret_type, body): > else: > make_declarations(s, already_declared) > make_declarations(body) > - return declarations.values() + \ > + return list(declarations.values()) + \ > [['function', f_name, ['signature', ret_type, > ['parameters'], body]]] > > > diff --git a/src/compiler/glsl/tests/optimization_test.py > b/src/compiler/glsl/tests/optimization_test.py > index 577d2dfc20f..b3147ed08fc 100755 > --- a/src/compiler/glsl/tests/optimization_test.py > +++ b/src/compiler/glsl/tests/optimization_test.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python2 > +#!/usr/bin/env python > # encoding=utf-8 > # Copyright © 2018 Intel Corporation > > @@ -71,7 +71,9 @@ def main(): > stdout=subprocess.PIPE, > stderr=subprocess.PIPE, > stdin=subprocess.PIPE) > - out, err = proc.communicate(source) > + out, err = proc.communicate(source.encode('utf-8')) > + out = out.decode('utf-8') > + err = err.decode('utf-8') > if err: > print('FAIL') > print('Unexpected output on stderr: {}'.format(err), > diff --git a/src/compiler/glsl/tests/sexps.py > b/src/compiler/glsl/tests/sexps.py > index a714af8d236..7939b42f9a2 100644 > --- a/src/compiler/glsl/tests/sexps.py > +++ b/src/compiler/glsl/tests/sexps.py > @@ -28,6 +28,11 @@ > # as ['constant', 'float', ['1.000000']]. > > import re > +import sys > +if sys.version_info >= (3, 0, 0): > + STRING_TYPE = str > +else: > + STRING_TYPE = unicode > > def check_sexp(sexp): > """Verify that the argument is a proper sexp. > @@ -39,7 +44,7 @@ def check_sexp(sexp): > if isinstance(sexp, list): > for s in sexp: > check_sexp(s) > - elif not isinstance(sexp, basestring): > + elif not isinstance(sexp, (STRING_TYPE, bytes)): > raise Exception('Not a sexp: {0!r}'.format(sexp)) > > def parse_sexp(sexp): > @@ -70,8 +75,10 @@ def sexp_to_string(sexp): > """Convert a sexp, represented as nested lists containing > strings, > into a single string of the form parseable by mesa. > """ > - if isinstance(sexp, basestring): > + if isinstance(sexp, STRING_TYPE): > return sexp > + if isinstance(sexp, bytes): > + return sexp.encode('utf-8') > assert isinstance(sexp, list) > result = '' > for s in sexp: _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev