Re: [Piglit] [PATCH] find_static_tests.py: fix python2 compatibility

2018-05-03 Thread Brian Paul

On 05/02/2018 11:52 AM, Dylan Baker wrote:

Because python2 uses bytes, but python3 uses unicode.

CC: Michel Dänzer 
Fixes: d42d909cd754d0e2c41eec60f3a1015f2d882b95
("tests: Add script to find all hand written test files")
---
  tests/find_static_tests.py | 11 ++-
  1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tests/find_static_tests.py b/tests/find_static_tests.py
index 215273159..795a56dc9 100644
--- a/tests/find_static_tests.py
+++ b/tests/find_static_tests.py
@@ -28,6 +28,8 @@ import argparse
  import io
  import os
  
+import six

+
  
  def main():

  parser = argparse.ArgumentParser()
@@ -55,7 +57,14 @@ def main():
  for dirpath, _, filenames in os.walk(directory):
  for filename in filenames:
  if os.path.splitext(filename)[1] in exts:
-files.append(os.path.join(dirpath, filename))
+name = os.path.join(dirpath, filename)
+if six.PY2:
+# This might not be correct, but it's fine. As long as the
+# two files are the same it'll work, and utf-8 is what
+# everyone *should* be using, and as a superset of ascii
+# *should* cover most people
+name = name.decode('utf-8', 'replace')
+files.append(name)
  
  if os.path.exists(args.output):

  with io.open(args.output, 'rt', encoding='utf-8') as f:



This seems to fix the failure on MinGW.

Tested-by: Brian Paul 

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] find_static_tests.py: fix python2 compatibility

2018-05-03 Thread Dylan Baker
Brian, Ilia,

This was the patch I had written.

Dylan

Quoting Dylan Baker (2018-05-02 10:52:47)
> Because python2 uses bytes, but python3 uses unicode.
> 
> CC: Michel Dänzer 
> Fixes: d42d909cd754d0e2c41eec60f3a1015f2d882b95
>("tests: Add script to find all hand written test files")
> ---
>  tests/find_static_tests.py | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/find_static_tests.py b/tests/find_static_tests.py
> index 215273159..795a56dc9 100644
> --- a/tests/find_static_tests.py
> +++ b/tests/find_static_tests.py
> @@ -28,6 +28,8 @@ import argparse
>  import io
>  import os
>  
> +import six
> +
>  
>  def main():
>  parser = argparse.ArgumentParser()
> @@ -55,7 +57,14 @@ def main():
>  for dirpath, _, filenames in os.walk(directory):
>  for filename in filenames:
>  if os.path.splitext(filename)[1] in exts:
> -files.append(os.path.join(dirpath, filename))
> +name = os.path.join(dirpath, filename)
> +if six.PY2:
> +# This might not be correct, but it's fine. As long as 
> the
> +# two files are the same it'll work, and utf-8 is what
> +# everyone *should* be using, and as a superset of ascii
> +# *should* cover most people
> +name = name.decode('utf-8', 'replace')
> +files.append(name)
>  
>  if os.path.exists(args.output):
>  with io.open(args.output, 'rt', encoding='utf-8') as f:
> -- 
> 2.17.0
> 
> ___
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit


signature.asc
Description: signature
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] find_static_tests.py: fix python2 compatibility

2018-05-02 Thread Dylan Baker
Because python2 uses bytes, but python3 uses unicode.

CC: Michel Dänzer 
Fixes: d42d909cd754d0e2c41eec60f3a1015f2d882b95
   ("tests: Add script to find all hand written test files")
---
 tests/find_static_tests.py | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tests/find_static_tests.py b/tests/find_static_tests.py
index 215273159..795a56dc9 100644
--- a/tests/find_static_tests.py
+++ b/tests/find_static_tests.py
@@ -28,6 +28,8 @@ import argparse
 import io
 import os
 
+import six
+
 
 def main():
 parser = argparse.ArgumentParser()
@@ -55,7 +57,14 @@ def main():
 for dirpath, _, filenames in os.walk(directory):
 for filename in filenames:
 if os.path.splitext(filename)[1] in exts:
-files.append(os.path.join(dirpath, filename))
+name = os.path.join(dirpath, filename)
+if six.PY2:
+# This might not be correct, but it's fine. As long as the
+# two files are the same it'll work, and utf-8 is what
+# everyone *should* be using, and as a superset of ascii
+# *should* cover most people
+name = name.decode('utf-8', 'replace')
+files.append(name)
 
 if os.path.exists(args.output):
 with io.open(args.output, 'rt', encoding='utf-8') as f:
-- 
2.17.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit