[Piglit] [PATCH 6/6] framework: Use explicit relative imports to be Python 3 compatible.

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


Python 3 dropped support for implicit relative imports, since the
statement 'import core' would be ambiguous if there were a module
named 'core' installed system wide and a similarly named module in the
current package.

Using a leading '.' means to import it from the current module
directory.  This is the approach taken by the 2to3 command.

For more information, see:
http://stackoverflow.com/questions/12172791/changes-in-import-statement-python3

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 framework/core.py             | 8 ++++----
 framework/exectest.py         | 2 +-
 framework/gleantest.py        | 4 ++--
 framework/glsl_parser_test.py | 4 ++--
 framework/log.py              | 4 ++--
 framework/shader_test.py      | 4 ++--
 framework/summary.py          | 2 +-
 framework/threads.py          | 4 ++--
 8 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/framework/core.py b/framework/core.py
index 4d7fcd6..442f075 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -31,13 +31,13 @@ import stat
 import subprocess
 import string
 import sys
+import threading
 import time
 import traceback
-from log import log
 from textwrap import dedent
-from threads import ConcurrentTestPool
-from threads import synchronized_self
-import threading
+from .log import log
+from .threads import ConcurrentTestPool
+from .threads import synchronized_self
 try:
     from cStringIO import StringIO # The Python 2.x import
 except:
diff --git a/framework/exectest.py b/framework/exectest.py
index 652ff4d..21fd1b0 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -26,7 +26,7 @@ import subprocess
 import shlex
 import types
 
-from core import Test, testBinDir, TestResult
+from .core import Test, testBinDir, TestResult
 
 #############################################################################
 ##### Platform global variables
diff --git a/framework/gleantest.py b/framework/gleantest.py
index 1143ebf..fec91cf 100644
--- a/framework/gleantest.py
+++ b/framework/gleantest.py
@@ -23,8 +23,8 @@
 import os
 import subprocess
 
-from core import checkDir, testBinDir, Test, TestResult
-from exectest import ExecTest
+from .core import checkDir, testBinDir, Test, TestResult
+from .exectest import ExecTest
 
 #############################################################################
 ##### GleanTest: Execute a sub-test of Glean
diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
index 9c1d973..c141f0b 100755
--- a/framework/glsl_parser_test.py
+++ b/framework/glsl_parser_test.py
@@ -47,8 +47,8 @@ import re
 import subprocess
 import sys
 
-from core import Test, testBinDir, TestResult
-from exectest import PlainExecTest
+from .core import Test, testBinDir, TestResult
+from .exectest import PlainExecTest
 
 def add_glsl_parser_test(group, filepath, test_name):
 	"""Add an instance of GLSLParserTest to the given group."""
diff --git a/framework/log.py b/framework/log.py
index e90137a..bca460c 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -21,8 +21,8 @@
 # IN THE SOFTWARE.
 #
 
-from threads import synchronized_self
-from patterns import Singleton
+from .threads import synchronized_self
+from .patterns import Singleton
 import logging
 
 class Logger(Singleton):
diff --git a/framework/shader_test.py b/framework/shader_test.py
index 48a9085..d35848f 100755
--- a/framework/shader_test.py
+++ b/framework/shader_test.py
@@ -31,8 +31,8 @@ import re
 import sys
 import textwrap
 
-from core import testBinDir, Group, Test, TestResult
-from exectest import PlainExecTest
+from .core import testBinDir, Group, Test, TestResult
+from .exectest import PlainExecTest
 
 """This module enables running shader tests.
 
diff --git a/framework/summary.py b/framework/summary.py
index a72bb4b..c2a7f00 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -20,7 +20,7 @@
 # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 # DEALINGS IN THE SOFTWARE.
 
-import core
+import .core
 
 
 #############################################################################
diff --git a/framework/threads.py b/framework/threads.py
index 724e84e..b092d76 100644
--- a/framework/threads.py
+++ b/framework/threads.py
@@ -21,8 +21,8 @@
 # IN THE SOFTWARE.
 #
 
-from threadpool import ThreadPool, WorkRequest
-from patterns import Singleton
+from .threadpool import ThreadPool, WorkRequest
+from .patterns import Singleton
 from threading import RLock
 from weakref import WeakKeyDictionary
 import multiprocessing
-- 
1.8.2.1



More information about the Piglit mailing list