mirror of https://github.com/pallets/flask.git
use importlib instead of pkgutil
This commit is contained in:
parent
367e1df785
commit
84e11a1e82
|
@ -3,6 +3,8 @@ Version 2.3.3
|
|||
|
||||
Unreleased
|
||||
|
||||
- Python 3.12 compatibility.
|
||||
|
||||
|
||||
Version 2.3.2
|
||||
-------------
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
import pkgutil
|
||||
import socket
|
||||
import sys
|
||||
import typing as t
|
||||
|
@ -575,7 +575,8 @@ def get_root_path(import_name: str) -> str:
|
|||
return os.path.dirname(os.path.abspath(mod.__file__))
|
||||
|
||||
# Next attempt: check the loader.
|
||||
loader = pkgutil.get_loader(import_name)
|
||||
spec = importlib.util.find_spec(import_name)
|
||||
loader = spec.loader if spec is not None else None
|
||||
|
||||
# Loader does not exist or we're referring to an unloaded main
|
||||
# module or a main module without path (interactive sessions), go
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
|||
import importlib.util
|
||||
import os
|
||||
import pathlib
|
||||
import pkgutil
|
||||
import sys
|
||||
import typing as t
|
||||
from collections import defaultdict
|
||||
|
@ -856,7 +855,8 @@ def _find_package_path(import_name):
|
|||
return os.path.dirname(root_spec.origin)
|
||||
|
||||
# we were unable to find the `package_path` using PEP 451 loaders
|
||||
loader = pkgutil.get_loader(root_mod_name)
|
||||
spec = importlib.util.find_spec(root_mod_name)
|
||||
loader = spec.loader if spec is not None else None
|
||||
|
||||
if loader is None or root_mod_name == "__main__":
|
||||
# import name is not found, or interactive/main module
|
||||
|
|
Loading…
Reference in New Issue