[Python-checkins] cpython: Use importlib instead of calling __import__ directly.

brett.cannon python-checkins at python.org
Wed Nov 14 21:23:08 CET 2012


http://hg.python.org/cpython/rev/379d48b56d95
changeset:   80427:379d48b56d95
parent:      80425:6f0e49ed0589
user:        Brett Cannon <brett at python.org>
date:        Wed Nov 14 13:42:51 2012 -0500
summary:
  Use importlib instead of calling __import__ directly.

files:
  Lib/test/regrtest.py |  3 +--
  1 files changed, 1 insertions(+), 2 deletions(-)


diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1210,8 +1210,7 @@
             abstest = 'test.' + test
         with saved_test_environment(test, verbose, quiet) as environment:
             start_time = time.time()
-            the_package = __import__(abstest, globals(), locals(), [])
-            the_module = getattr(the_package, test)
+            the_module = importlib.import_module(abstest)
             # If the test has a test_main, that will run the appropriate
             # tests.  If not, use normal unittest test loading.
             test_runner = getattr(the_module, "test_main", None)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list