Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lib/importlib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import _imp
import sys
import threading
import types


Expand Down Expand Up @@ -253,6 +252,9 @@ def create_module(self, spec):

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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Defer the ``threading`` import in ``importlib.util`` until lazy loading is
used.