[Piglit] [PATCH 2/6] framework: Make configparser import work in Python 3.x as well.

Kenneth Graunke kenneth at whitecape.org
Wed Apr 17 02:53:54 PDT 2013


From: Jon Severinsson <jon at severinsson.net>

First, we can try to import it via the Python 3.x name.  If that fails,
we can try the Python 2.x name.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 framework/glsl_parser_test.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
index 4f84ef8..d0d93bf 100755
--- a/framework/glsl_parser_test.py
+++ b/framework/glsl_parser_test.py
@@ -31,7 +31,10 @@ standalone tests on the command line. To add a test to a Piglit group, us
 
 usage_message = "usage: glsl_parser_test.py TEST_FILE"
 
-import ConfigParser as configparser
+try:
+    import configparser # The Python 3.x name
+except ImportError:
+    import ConfigParser as configparser # The Python 2.x name
 import os
 import os.path as path
 import re
-- 
1.8.2.1



More information about the Piglit mailing list