mirror of
https://github.com/python-pillow/Pillow.git
synced 2026-01-28 11:05:49 +03:00
Use __spec__.parent instead of calculating each time
This commit is contained in:
parent
c036185514
commit
2b186fceb8
|
|
@ -416,7 +416,7 @@ def _import_plugin_for_extension(ext: str | bytes) -> bool:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.debug("Importing %s", plugin)
|
logger.debug("Importing %s", plugin)
|
||||||
__import__(f"PIL.{plugin}", globals(), locals(), [])
|
__import__(f"{__spec__.parent}.{plugin}", globals(), locals(), [])
|
||||||
return True
|
return True
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
logger.debug("Image: failed to import %s: %s", plugin, e)
|
logger.debug("Image: failed to import %s: %s", plugin, e)
|
||||||
|
|
@ -481,11 +481,10 @@ def init() -> bool:
|
||||||
if _initialized >= 2:
|
if _initialized >= 2:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
parent_name = __name__.rpartition(".")[0]
|
|
||||||
for plugin in _plugins:
|
for plugin in _plugins:
|
||||||
try:
|
try:
|
||||||
logger.debug("Importing %s", plugin)
|
logger.debug("Importing %s", plugin)
|
||||||
__import__(f"{parent_name}.{plugin}", globals(), locals(), [])
|
__import__(f"{__spec__.parent}.{plugin}", globals(), locals(), [])
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
logger.debug("Image: failed to import %s: %s", plugin, e)
|
logger.debug("Image: failed to import %s: %s", plugin, e)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user