Fixing a bug related to plugin file names.

Fixed a bug where plugins don't run due to them being named same as inbuilt module from standard library of python.
This commit is contained in:
Vishal 2024-07-25 20:45:55 +05:30 committed by GitHub
parent aceb9a1a66
commit c3754bd0c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@
"""Utility snippets applying to generic Python code."""
from __future__ import annotations
import sys
import types
import weakref
import random
@ -79,6 +80,8 @@ def getclass(name: str, subclassof: type[T]) -> type[T]:
splits = name.split('.')
modulename = '.'.join(splits[:-1])
classname = splits[-1]
if modulename in sys.stdlib_module_names:
raise Exception(f'{modulename} is an inbuilt module.')
module = importlib.import_module(modulename)
cls: type = getattr(module, classname)