[Piglit] [PATCH 06/20] framework: Make StringIO import Python 3.x compatible.
Jon Severinsson
jon at severinsson.net
Wed Apr 17 09:14:45 PDT 2013
StringIO comes from the 'cStringIO' module in Python 2.x, and from the
'io' module in Python 3.x.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
framework/core.py | 6 +++++-
framework/glsl_parser_test.py | 5 ++++-
2 filer ändrade, 9 tillägg(+), 2 borttagningar(-)
diff --git a/framework/core.py b/framework/core.py
index c8ddfd3..f871409 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -37,10 +37,14 @@ import string
import sys
import time
import traceback
-from cStringIO import StringIO
from textwrap import dedent
import threading
+try:
+ from cStringIO import StringIO # The Python 2.x import
+except ImportError:
+ from io import StringIO # The Python 3.x import
+
__all__ = [
'Environment',
'checkDir',
diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
index bfacb3c..6f7d4df 100755
--- a/framework/glsl_parser_test.py
+++ b/framework/glsl_parser_test.py
@@ -39,12 +39,15 @@ import os.path as path
import re
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
+try:
+ from cStringIO import StringIO # The Python 2.x import
+except ImportError:
+ from io import StringIO # The Python 3.x import
def add_glsl_parser_test(group, filepath, test_name):
"""Add an instance of GLSLParserTest to the given group."""
--
1.7.10.4
More information about the Piglit
mailing list