Skip to content

Commit 848a12d

Browse files
[LNT] Python 3 support: Fix implicit package-relative imports
Summary: This patch replaces implicit package-relative imports with explicitly relative imports and makes further adjustments necessary to correct for circular import issues encountered when running with Python 2.7 following the initial changes. Finally, `from __future__ import absolute_import` is added to all of the files changed as part of this exercise. These changes help with running tests (without result submission) with Python 3. Reviewers: cmatthews, thopre, kristof.beyls, MaskRay Reviewed By: MaskRay Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D67795 llvm-svn: 372404
1 parent e1a4c99 commit 848a12d

File tree

9 files changed

+23
-14
lines changed

9 files changed

+23
-14
lines changed

lnt/external/stats/pstat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@
105105
##
106106
## 11/08/98 ... fixed aput to output large arrays correctly
107107

108+
from __future__ import absolute_import
108109
from __future__ import print_function
109-
import stats # required 3rd party module
110110
import string, copy
111111
from types import *
112112

lnt/external/stats/stats.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,9 @@
222222
## changed name of skewness and askewness to skew and askew
223223
## fixed (a)histogram (which sometimes counted points <lowerlimit)
224224

225+
from __future__ import absolute_import
225226
from __future__ import print_function
226-
import pstat # required 3rd party module
227+
from . import pstat # required 3rd party module
227228
import math, string, copy # required python modules
228229
from types import *
229230

lnt/formats/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
callable taking a Python object to write, and the path_or_file to write to.
88
"""
99

10-
from PlistFormat import format as plist
11-
from JSONFormat import format as json
10+
from __future__ import absolute_import
11+
from .PlistFormat import format as plist
12+
from .JSONFormat import format as json
1213

1314
formats = [plist, json]
1415
formats_by_name = dict((f['name'], f) for f in formats)

lnt/lnttool/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from main import main
1+
from __future__ import absolute_import
2+
from .main import main

lnt/server/db/testsuite.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
Database models for the TestSuites abstraction.
33
"""
44

5+
from __future__ import absolute_import
56
import json
67
import lnt
7-
import testsuitedb
8-
import util
8+
from . import util
99

1010
import sqlalchemy
1111
import sqlalchemy.ext.declarative
@@ -114,6 +114,7 @@ def __repr__(self):
114114

115115
@staticmethod
116116
def from_json(data):
117+
from . import testsuitedb
117118
if data.get('format_version') != '2':
118119
raise ValueError("Expected \"format_version\": \"2\" in schema")
119120
name = data['name']
@@ -349,6 +350,7 @@ def copy_info(self, other):
349350

350351

351352
def _upgrade_to(connectable, tsschema, new_schema, dry_run=False):
353+
from . import testsuitedb
352354
new = json.loads(new_schema.jsonschema)
353355
old = json.loads(tsschema.jsonschema)
354356
ts_name = new['name']

lnt/server/db/testsuitedb.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
suite metadata, so we only create the classes at runtime.
66
"""
77

8+
from __future__ import absolute_import
89
import datetime
910
import json
1011
import os
@@ -18,7 +19,7 @@
1819
from typing import List
1920
from lnt.util import logger
2021

21-
import testsuite
22+
from . import testsuite
2223
import lnt.testing.profile.profile as profile
2324
import lnt
2425
from lnt.server.ui.util import convert_revision

lnt/testing/profile/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# This is the profile implementation registry. Register new profile
22
# implementations here.
33

4-
from profilev1impl import ProfileV1
5-
from profilev2impl import ProfileV2
6-
from perf import LinuxPerfProfile
4+
from __future__ import absolute_import
5+
from .profilev1impl import ProfileV1
6+
from .profilev2impl import ProfileV2
7+
from .perf import LinuxPerfProfile
78
IMPLEMENTATIONS = {0: LinuxPerfProfile, 1: ProfileV1, 2: ProfileV2}

lnt/testing/profile/perf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from __future__ import absolute_import
12
from lnt.util import logger
2-
from profile import ProfileImpl
3-
from profilev1impl import ProfileV1
3+
from .profile import ProfileImpl
4+
from .profilev1impl import ProfileV1
45

56
import os
67
import traceback

lnt/testing/profile/profilev2impl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from profile import ProfileImpl
1+
from __future__ import absolute_import
2+
from .profile import ProfileImpl
23
import StringIO
34
import bz2
45
import copy

0 commit comments

Comments
 (0)