On Thu, 2018-08-16 at 14:21 -0700, Dylan Baker wrote: > --- > > I didn't see any patches from anyone else, so I wrote some real > quick. Please > point to them if other patches already exist.
I was about to send mine, but you were faster. >_< They ar every similar though, except that you missed glcpp_test.py, which requires a few more changes. (I have them ready, and can send them separately) > diff --git a/src/compiler/glsl/tests/optimization_test.py > b/src/compiler/glsl/tests/optimization_test.py > index 577d2dfc20f..f40d0cee6bd 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()) > + out = out.decode() > + err = err.decode() I usually find it too unpredictable to use the default encoding, and prefer always specifying 'utf-8'. (even on Python 3, you can't be sure that will always be the default) > diff --git a/src/compiler/glsl/tests/sexps.py > b/src/compiler/glsl/tests/sexps.py > index a714af8d236..b69d3a5e5d7 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): > + STRINGS = str > +else: > + STRINGS = (str, 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, STRINGS): > raise Exception('Not a sexp: {0!r}'.format(sexp)) > > def parse_sexp(sexp): > @@ -70,7 +75,7 @@ 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, STRINGS): > return sexp Someone on this list ( :P ) once told me to avoid mising bytes and strings. In this case, I believe the patch would be better as follows: - if isinstance(sexp, basestring): + if isinstance(sexp, bytes): + return sexp.decode('utf-8') + if isinstance(sexp, string_type): return sexp And then the previous hunks can be: +if sys.version_info < (3, 0): + string_type = unicode +else: + string_type = str … - elif not isinstance(sexp, basestring): + elif not isinstance(sexp, (string_type, bytes)): -- Mathieu _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev