[Lldb-commits] [PATCH] D14342: Enable absolute imports in lldbsuite

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 4 11:16:38 PST 2015


zturner created this revision.
zturner added a reviewer: tfiala.
zturner added a subscriber: lldb-commits.

    Enable absolute imports in lldbsuite.

    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.

http://reviews.llvm.org/D14342

Files:
  packages/Python/lldbsuite/test/__init__.py
  packages/Python/lldbsuite/test/bench.py
  packages/Python/lldbsuite/test/curses_results.py
  packages/Python/lldbsuite/test/dosep.py
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/dotest_args.py
  packages/Python/lldbsuite/test/dotest_channels.py
  packages/Python/lldbsuite/test/lldb_pylint_helper.py
  packages/Python/lldbsuite/test/lldbbench.py
  packages/Python/lldbsuite/test/lldbcurses.py
  packages/Python/lldbsuite/test/lldbinline.py
  packages/Python/lldbsuite/test/lldbpexpect.py
  packages/Python/lldbsuite/test/lldbplatformutil.py
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/lldbutil.py
  packages/Python/lldbsuite/test/test_categories.py
  packages/Python/lldbsuite/test/test_results.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14342.39222.patch
Type: text/x-patch
Size: 12656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151104/77da376d/attachment-0001.bin>


More information about the lldb-commits mailing list