[Piglit] [PATCH 04/20] framework: Make configparser import Python 3.x compatible.

Jon Severinsson jon at severinsson.net
Wed Apr 17 09:14:43 PDT 2013


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 |    6 +++++-
 1 fil ändrad, 5 tillägg(+), 1 borttagning(-)

diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
index 9b081ef..bfacb3c 100755
--- a/framework/glsl_parser_test.py
+++ b/framework/glsl_parser_test.py
@@ -34,7 +34,6 @@ usage_message = "usage: glsl_parser_test.py TEST_FILE"
 from .core import Test, testBinDir, TestResult
 from .exectest import PlainExecTest
 
-import ConfigParser as configparser
 import os
 import os.path as path
 import re
@@ -42,6 +41,11 @@ import subprocess
 import sys
 from cStringIO import StringIO
 
+try:
+    import configparser # The Python 3.x name
+except ImportError:
+    import ConfigParser as configparser # The Python 2.x name
+
 def add_glsl_parser_test(group, filepath, test_name):
 	"""Add an instance of GLSLParserTest to the given group."""
 	group[test_name] = GLSLParserTest(filepath)
-- 
1.7.10.4



More information about the Piglit mailing list