Don't cache duplicate plugin names (#34420)

* Don't cache duplicate plugin names. Fixes #33484

* Add tests for duplicate plugin filenames, to showcase what happens
This commit is contained in:
Matt Martz 2018-01-04 16:47:23 -06:00 committed by GitHub
parent edf56c9743
commit aece0818c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 1 deletions

View file

@ -424,7 +424,14 @@ class PluginLoader:
continue
if path not in self._module_cache:
self._module_cache[path] = self._load_module_source(name, path)
module = self._load_module_source(name, path)
if module in self._module_cache.values():
# In ``_load_module_source`` if a plugin has a duplicate name, we just return the
# previously matched plugin from sys.modules, which means you are never getting both,
# just one, but cached for both paths, this isn't normally a problem, except with callbacks
# where it will run that single callback twice. This rejects duplicates.
continue
self._module_cache[path] = module
found_in_cache = False
try: