summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/util.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py
index 7243d05..8403ef9 100644
--- a/Lib/importlib/util.py
+++ b/Lib/importlib/util.py
@@ -13,7 +13,6 @@ from ._bootstrap_external import spec_from_file_location
import _imp
import sys
-import threading
import types
@@ -257,6 +256,9 @@ class LazyLoader(Loader):
def exec_module(self, module):
"""Make the module load lazily."""
+ # Threading is only needed for lazy loading, and importlib.util can
+ # be pulled in at interpreter startup, so defer until needed.
+ import threading
module.__spec__.loader = self.loader
module.__loader__ = self.loader
# Don't need to worry about deep-copying as trying to set an attribute