From 385a49c5f44ec62536036a7bb8927e05cc2e0d81 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 3 Jul 2016 19:50:11 +0200 Subject: [PATCH] Compatible module loading for zip modules #234 --- patacrep/files.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/patacrep/files.py b/patacrep/files.py index 1ad296d5..7a9b29ef 100644 --- a/patacrep/files.py +++ b/patacrep/files.py @@ -8,6 +8,7 @@ import pkgutil import posixpath import re import sys +from zipimport import ZipImportError from patacrep import utils from patacrep import __DATADIR__ @@ -90,6 +91,13 @@ def iter_modules(path, prefix): else: try: yield module_finder.find_spec(name).loader.load_module() + except AttributeError: + # It is a zipimport.zipimporter object + try: + yield module_finder.load_module(name) + except ZipImportError as error: + LOGGER.debug("[plugins] Could not load module {}: {}".format(name, str(error))) + continue except ImportError as error: LOGGER.debug("[plugins] Could not load module {}: {}".format(name, str(error))) continue