Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import plugins relative to the module #7576

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,11 @@
if _initialized >= 2:
return 0

parent_module, _, _ = __name__.rpartition(".")

Check warning on line 358 in src/PIL/Image.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/Image.py#L358

Added line #L358 was not covered by tests
deliangyang marked this conversation as resolved.
Show resolved Hide resolved
for plugin in _plugins:
try:
logger.debug("Importing %s", plugin)
__import__(f"PIL.{plugin}", globals(), locals(), [])
__import__(f"{parent_module}.{plugin}", globals(), locals(), [])

Check warning on line 362 in src/PIL/Image.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/Image.py#L362

Added line #L362 was not covered by tests
deliangyang marked this conversation as resolved.
Show resolved Hide resolved
except ImportError as e:
logger.debug("Image: failed to import %s: %s", plugin, e)

Expand Down