Skip to content

Commit be3e1ae

Browse files
authored
Fix conf.exts.load() on Python 3.8 (#4808)
1 parent 1e7a629 commit be3e1ae

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scapy/config.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,18 @@ def load(self, extension: str):
631631
try:
632632
import importlib.metadata
633633
except ImportError:
634-
raise ImportError("Cannot import importlib.metadata ! Upgrade Python.")
634+
log_loading.warning(
635+
"'%s' not loaded. "
636+
"Scapy extensions require at least Python 3.8+ !" % extension
637+
)
638+
return
635639

636640
# Get extension distribution
637-
distr = importlib.metadata.distribution(extension)
641+
try:
642+
distr = importlib.metadata.distribution(extension)
643+
except importlib.metadata.PackageNotFoundError:
644+
log_loading.warning("The extension '%s' was not found !" % extension)
645+
return
638646

639647
# Check the classifiers
640648
if distr.metadata.get('License-Expression', None) not in self.GPLV2_LICENCES:

0 commit comments

Comments
 (0)