[Lldb-commits] [lldb] r252191 - Python 3 - Turn on absolute imports, and fix existing imports.
Chaoren Lin via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 5 13:53:55 PST 2015
Hi, I think this changed caused all of the OS X tests to fail:
http://lab.llvm.org:8011/builders/lldb-x86_64-darwin-13.4/builds/6969/steps/test1/logs/stdio
with this error:
Traceback (most recent call last):
File "/Users/lldb_build/lldbSlave/buildDir/scripts/../lldb/test/dotest.py",
line 7, in <module>
lldbsuite.test.run_suite()
File "/Users/lldb_build/lldbSlave/buildDir/lldb/packages/Python/lldbsuite/test/dotest.py",
line 1487, in run_suite
setupCrashInfoHook()
File "/Users/lldb_build/lldbSlave/buildDir/lldb/packages/Python/lldbsuite/test/dotest.py",
line 390, in setupCrashInfoHook
import lock
ImportError: No module named lock
On Thu, Nov 5, 2015 at 11:22 AM, Zachary Turner via lldb-commits <
lldb-commits at lists.llvm.org> wrote:
> Author: zturner
> Date: Thu Nov 5 13:22:28 2015
> New Revision: 252191
>
> URL: http://llvm.org/viewvc/llvm-project?rev=252191&view=rev
> Log:
> Python 3 - Turn on absolute imports, and fix existing imports.
>
> Absolute imports were introduced in Python 2.5 as a feature
> (e.g. from __future__ import absolute_import), and made default
> in Python 3.
>
> When absolute imports are enabled, the import system changes in
> a couple of ways:
>
> 1) The `import foo` syntax will *only* search sys.path. If `foo`
> isn't in sys.path, it won't be found. Period. Without absolute
> imports, the import system will also search the same directory
> that the importing file resides in, so that you can easily
> import from the same folder.
>
> 2) From inside a package, you can use a dot syntax to refer to higher
> levels of the current package. For example, if you are in the
> package lldbsuite.test.utility, then ..foo refers to
> lldbsuite.test.foo. You can use this notation with the
> `from X import Y` syntax to write intra-package references. For
> example, using the previous locationa s a starting point, writing
> `from ..support import seven` would import lldbsuite.support.seven
>
> Since this is now the default behavior in Python 3, this means that
> importing from the same directory with `import foo` *no longer works*.
> As a result, the only way to have portable code is to force absolute
> imports for all versions of Python.
>
> See PEP 0328 [https://www.python.org/dev/peps/pep-0328/] for more
> information about absolute and relative imports.
>
> Differential Revision: http://reviews.llvm.org/D14342
> Reviewed By: Todd Fiala
>
> Modified:
> lldb/trunk/packages/Python/lldbsuite/test/__init__.py
> lldb/trunk/packages/Python/lldbsuite/test/bench.py
> lldb/trunk/packages/Python/lldbsuite/test/curses_results.py
> lldb/trunk/packages/Python/lldbsuite/test/dosep.py
> lldb/trunk/packages/Python/lldbsuite/test/dotest.py
> lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
> lldb/trunk/packages/Python/lldbsuite/test/dotest_channels.py
> lldb/trunk/packages/Python/lldbsuite/test/lldb_pylint_helper.py
> lldb/trunk/packages/Python/lldbsuite/test/lldbbench.py
> lldb/trunk/packages/Python/lldbsuite/test/lldbcurses.py
> lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
> lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py
> lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py
> lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
> lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
> lldb/trunk/packages/Python/lldbsuite/test/test_categories.py
> lldb/trunk/packages/Python/lldbsuite/test/test_results.py
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/__init__.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/__init__.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/__init__.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/__init__.py Thu Nov 5
> 13:22:28 2015
> @@ -1,4 +1,6 @@
> # Module level initialization for the `lldbsuite.test` module.
>
> -import dotest
> +from __future__ import absolute_import
> +
> +from . import dotest
> run_suite = dotest.run_suite
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/bench.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/bench.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/bench.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/bench.py Thu Nov 5 13:22:28
> 2015
> @@ -15,6 +15,7 @@ See also bench-history.
> """
>
> from __future__ import print_function
> +from __future__ import absolute_import
>
> import os, sys
> import re
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/curses_results.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/curses_results.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/curses_results.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/curses_results.py Thu Nov 5
> 13:22:28 2015
> @@ -10,15 +10,21 @@ Configuration options for lldbtest.py se
> """
>
> from __future__ import print_function
> +from __future__ import absolute_import
>
> +# System modules
> import curses
> import datetime
> -import lldbcurses
> import math
> import sys
> import test_results
> import time
>
> +# Third-party modules
> +
> +# LLDB modules
> +from . import lldbcurses
> +
> class Curses(test_results.ResultsFormatter):
> """Receives live results from tests that are running and reports them
> to the terminal in a curses GUI"""
>
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/dosep.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dosep.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/dosep.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/dosep.py Thu Nov 5 13:22:28
> 2015
> @@ -33,8 +33,7 @@ echo core.%p | sudo tee /proc/sys/kernel
> """
>
> from __future__ import print_function
> -
> -
> +from __future__ import absolute_import
>
> # system packages and modules
> import asyncore
> @@ -51,15 +50,17 @@ import threading
>
> from six.moves import queue
>
> -# Add our local test_runner/lib dir to the python path.
> -sys.path.append(os.path.join(os.path.dirname(__file__), "test_runner",
> "lib"))
> -
> # Our packages and modules
> -import dotest_channels
> -import dotest_args
> +import lldbsuite.support.seven as seven
> +
> +from . import dotest_channels
> +from . import dotest_args
> +
> +# Todo: Convert this folder layout to be relative-import friendly and
> don't hack up
> +# sys.path like this
> +sys.path.append(os.path.join(os.path.dirname(__file__), "test_runner",
> "lib"))
> import lldb_utils
> import process_control
> -import lldbsuite.support.seven as seven
>
> # Status codes for running command with timeout.
> eTimedOut, ePassed, eFailed = 124, 0, 1
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Thu Nov 5
> 13:22:28 2015
> @@ -18,16 +18,14 @@ Type:
> for available options.
> """
>
> +from __future__ import absolute_import
> from __future__ import print_function
> -import sys
> -
> -import lldbsuite
> -import lldbtest_config
>
> +# System modules
> +import sys
> import atexit
> import importlib
> import os
> -import dotest_args
> import errno
> import platform
> import progress
> @@ -35,14 +33,20 @@ import signal
> import socket
> import subprocess
> import sys
> -import test_results
> -from test_results import EventBuilder
> import inspect
> -import unittest2
> -import test_categories
>
> +# Third-party modules
> import six
> -import lldbsuite.support.seven as seven
> +import unittest2
> +
> +# LLDB Modules
> +import lldbsuite
> +from . import dotest_args
> +from . import lldbtest_config
> +from . import test_categories
> +from . import test_results
> +from .test_results import EventBuilder
> +from ..support import seven
>
> def is_exe(fpath):
> """Returns true if fpath is an executable."""
> @@ -1470,7 +1474,7 @@ def run_suite():
> # If we are running as the multiprocess test runner, kick off the
> # multiprocess test runner here.
> if isMultiprocessTestRunner():
> - import dosep
> + from . import dosep
> dosep.main(output_on_success, num_threads,
> multiprocess_test_subdir,
> test_runner_name, results_formatter_object)
> raise Exception("should never get here")
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py Thu Nov 5
> 13:22:28 2015
> @@ -1,11 +1,17 @@
> from __future__ import print_function
> +from __future__ import absolute_import
>
> +# System modules
> import argparse
> import sys
> import multiprocessing
> import os
> import textwrap
>
> +# Third-party modules
> +
> +# LLDB modules
> +
> class ArgParseNamespace(object):
> pass
>
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest_channels.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest_channels.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/dotest_channels.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/dotest_channels.py Thu Nov
> 5 13:22:28 2015
> @@ -15,14 +15,18 @@ framework.
> """
>
> from __future__ import print_function
> +from __future__ import absolute_import
>
>
> -
> +# System modules
> import asyncore
> import socket
>
> +# Third-party modules
> from six.moves import cPickle
>
> +# LLDB modules
> +
> class UnpicklingForwardingReaderChannel(asyncore.dispatcher):
> """Provides an unpickling, forwarding asyncore dispatch channel
> reader.
>
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lldb_pylint_helper.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldb_pylint_helper.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lldb_pylint_helper.py
> (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lldb_pylint_helper.py Thu
> Nov 5 13:22:28 2015
> @@ -13,12 +13,18 @@ Provides helper support for adding lldb
> """
>
> from __future__ import print_function
> +from __future__ import absolute_import
>
> +# System modules
> import os
> import platform
> import subprocess
> import sys
>
> +# Third-party modules
> +
> +# LLDB modules
> +
>
> def add_lldb_test_paths(check_dir):
> # pylint: disable=line-too-long
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbbench.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbbench.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lldbbench.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lldbbench.py Thu Nov 5
> 13:22:28 2015
> @@ -1,6 +1,12 @@
> +from __future__ import absolute_import
> +
> +# System modules
> import time
> -#import numpy
> -from lldbtest import *
> +
> +# Third-party modules
> +
> +# LLDB modules
> +from .lldbtest import *
>
> class Stopwatch(object):
> """Stopwatch provides a simple utility to start/stop your stopwatch
> multiple
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbcurses.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbcurses.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lldbcurses.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lldbcurses.py Thu Nov 5
> 13:22:28 2015
> @@ -1,10 +1,16 @@
> +from __future__ import absolute_import
>
> -
> -import curses, curses.panel
> +# System modules
> +import curses
> +import curses.panel
> import sys
> -import six
> import time
>
> +# Third-party modules
> +import six
> +
> +# LLDB modules
> +
> class Point(object):
> def __init__(self, x, y):
> self.x = x
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py Thu Nov 5
> 13:22:28 2015
> @@ -1,11 +1,17 @@
> from __future__ import print_function
> +from __future__ import absolute_import
>
> -import lldb
> -from lldbtest import *
> -import lldbutil
> +# System modules
> import os
> import sys
>
> +# Third-party modules
> +
> +# LLDB modules
> +import lldb
> +from .lldbtest import *
> +from . import lldbutil
> +
> def source_type(filename):
> _, extension = os.path.splitext(filename)
> return {
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py Thu Nov 5
> 13:22:28 2015
> @@ -1,14 +1,18 @@
> from __future__ import print_function
> +from __future__ import absolute_import
>
> -
> -
> -import lldb
> -from lldbtest import *
> -import lldbutil
> +# System modules
> import os
> import sys
> +
> +# Third-party modules
> import pexpect
>
> +# LLDB Modules
> +import lldb
> +from .lldbtest import *
> +from . import lldbutil
> +
> class PExpectTest(TestBase):
>
> mydir = TestBase.compute_mydir(__file__)
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py
> (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py Thu Nov
> 5 13:22:28 2015
> @@ -1,6 +1,14 @@
> """ This module contains functions used by the test cases to hide the
> architecture and/or the platform dependent nature of the tests. """
>
> +from __future__ import absolute_import
> +
> +# System modules
> +
> +# Third-party modules
> +
> +# LLDB modules
> +
> def check_first_register_readable(test_case):
> if test_case.getArchitecture() in ['x86_64', 'i386']:
> test_case.expect("register read eax", substrs = ['eax = 0x'])
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Nov 5
> 13:22:28 2015
> @@ -32,10 +32,11 @@ $
> """
>
> from __future__ import print_function
> +from __future__ import absolute_import
>
> -
> -
> +# System modules
> import abc
> +import collections
> import gc
> import glob
> import os, sys, traceback
> @@ -45,17 +46,19 @@ import signal
> from subprocess import *
> import time
> import types
> -import unittest2
> -import lldb
> -import lldbtest_config
> -import lldbutil
> -import test_categories
>
> +# Third-party modules
> +import unittest2
> from six import add_metaclass
> from six import StringIO as SixStringIO
> from six.moves.urllib import parse as urlparse
> import six
> -import collections
> +
> +# LLDB modules
> +import lldb
> +from . import lldbtest_config
> +from . import lldbutil
> +from . import test_categories
>
> # dosep.py starts lots and lots of dotest instances
> # This option helps you find if two (or more) dotest instances are using
> the same
> @@ -1890,7 +1893,7 @@ class Base(unittest2.TestCase):
> """ Returns a string that represents the compiler version.
> Supports: llvm, clang.
> """
> - from lldbutil import which
> + from .lldbutil import which
> version = 'unknown'
>
> compiler = self.getCompilerBinary()
> @@ -2546,7 +2549,7 @@ class TestBase(Base):
> Run the 'thread list' command, and select the thread with stop
> reason as
> 'stop_reason'. If no such thread exists, no select action is
> done.
> """
> - from lldbutil import stop_reason_to_str
> + from .lldbutil import stop_reason_to_str
> self.runCmd('thread list')
> output = self.res.GetOutput()
> thread_line_pattern = re.compile("^[ *] thread #([0-9]+):.*stop
> reason = %s" %
> @@ -2801,7 +2804,7 @@ class TestBase(Base):
>
> def DebugSBValue(self, val):
> """Debug print a SBValue object, if traceAlways is True."""
> - from lldbutil import value_type_to_str
> + from .lldbutil import value_type_to_str
>
> if not traceAlways:
> return
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py Thu Nov 5
> 13:22:28 2015
> @@ -5,16 +5,21 @@ They can also be useful for general purp
> """
>
> from __future__ import print_function
> +from __future__ import absolute_import
>
> -
> -
> -import lldb
> -import os, sys
> +# System modules
> +import collections
> +import os
> import re
> +import sys
>
> +# Third-party modules
> from six import StringIO as SixStringIO
> import six
> -import collections
> +
> +# LLDB modules
> +import lldb
> +
>
> # ===================================================
> # Utilities for locating/checking executable programs
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/test_categories.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/test_categories.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/test_categories.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/test_categories.py Thu Nov
> 5 13:22:28 2015
> @@ -2,8 +2,15 @@
> Provides definitions for various lldb test categories
> """
>
> +from __future__ import absolute_import
> +
> +# System modules
> import sys
>
> +# Third-party modules
> +
> +# LLDB modules
> +
> all_categories = {
> 'dataformatters': 'Tests related to the type command and the data
> formatters subsystem',
> 'expression' : 'Tests related to the expression parser',
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/test_results.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/test_results.py?rev=252191&r1=252190&r2=252191&view=diff
>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/test_results.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/test_results.py Thu Nov 5
> 13:22:28 2015
> @@ -9,9 +9,9 @@ within the LLDB test suite.
> """
>
> from __future__ import print_function
> +from __future__ import absolute_import
>
> -
> -
> +# System modules
> import argparse
> import inspect
> import os
> @@ -23,9 +23,11 @@ import time
> import traceback
> import xml.sax.saxutils
>
> +# Third-party modules
> import six
> from six.moves import cPickle
>
> +# LLDB modules
>
> class EventBuilder(object):
> """Helper class to build test result event dictionaries."""
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151105/3d0f60ca/attachment-0001.html>
More information about the lldb-commits
mailing list