From 6825a7669285a32830017d808adcb936e26ea601 Mon Sep 17 00:00:00 2001 From: Deliang Yang Date: Mon, 27 Nov 2023 17:02:11 +0800 Subject: [PATCH 1/2] fix: Importing plugins from a user-specified installation directory [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci fix: Wrong path replacement [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci fix: typo --- src/PIL/Image.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index d435b561720..300c9ac323c 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -355,10 +355,11 @@ def init(): if _initialized >= 2: return 0 + parent_module, _, _ = __name__.rpartition(".") for plugin in _plugins: try: logger.debug("Importing %s", plugin) - __import__(f"PIL.{plugin}", globals(), locals(), []) + __import__(f"{parent_module}.{plugin}", globals(), locals(), []) except ImportError as e: logger.debug("Image: failed to import %s: %s", plugin, e) From b235aa98c6e6a8727239e5ae6e149707eca18f4c Mon Sep 17 00:00:00 2001 From: helloworld Date: Tue, 28 Nov 2023 20:21:03 +0800 Subject: [PATCH 2/2] fix: use parent_name instead of parent_module --- src/PIL/Image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 300c9ac323c..7c3826d92c5 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -355,11 +355,11 @@ def init(): if _initialized >= 2: return 0 - parent_module, _, _ = __name__.rpartition(".") + parent_name = __name__.rpartition(".")[0] for plugin in _plugins: try: logger.debug("Importing %s", plugin) - __import__(f"{parent_module}.{plugin}", globals(), locals(), []) + __import__(f"{parent_name}.{plugin}", globals(), locals(), []) except ImportError as e: logger.debug("Image: failed to import %s: %s", plugin, e)