File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
addons/source-python/packages/source-python/plugins Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1313from configobj import Section
1414# Importlib
1515from importlib .util import find_spec
16+ from importlib .util import spec_from_file_location
1617# Sys
1718import sys
1819# Re
@@ -177,8 +178,20 @@ def load(self, plugin_name):
177178 raise PluginFileNotFoundError (
178179 'File {} does not exist.' .format (plugin .file_path ))
179180
180- spec = find_spec (plugin .import_name )
181- if spec is None or spec .origin != plugin .file_path :
181+ spec = None
182+ if plugin_name not in sys .builtin_module_names :
183+ try :
184+ spec = find_spec (plugin .import_name )
185+ # AttributeError:
186+ # An existing .py module that do not have a __path__ attribute.
187+ # ValueError:
188+ # An existing .pyc/.pyd package that have its __spec__ attribute
189+ # set to None.
190+ except (AttributeError , ValueError ):
191+ pass
192+
193+ if spec is None or spec != spec_from_file_location (
194+ plugin .import_name , plugin .file_path ):
182195 raise PluginHasBuiltInName (
183196 'Plugin "{}" has the name of a built-in module.' .format (
184197 plugin_name ))
You can’t perform that action at this time.
0 commit comments