mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Catch an importlib warning.
This commit is contained in:
@@ -7,6 +7,7 @@ import imp
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import pkgutil
|
import pkgutil
|
||||||
|
import warnings
|
||||||
try:
|
try:
|
||||||
import importlib
|
import importlib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -60,6 +61,12 @@ def find_module_py33(string, path=None, loader=None, fullname=None):
|
|||||||
|
|
||||||
if loader is None and path is None: # Fallback to find builtins
|
if loader is None and path is None: # Fallback to find builtins
|
||||||
try:
|
try:
|
||||||
|
with warnings.catch_warnings(record=True):
|
||||||
|
# Mute "DeprecationWarning: Use importlib.util.find_spec()
|
||||||
|
# instead." While we should replace that in the future, it's
|
||||||
|
# probably good to wait until we deprecate Python 3.3, since
|
||||||
|
# it was added in Python 3.4 and find_loader hasn't been
|
||||||
|
# removed in 3.6.
|
||||||
loader = importlib.find_loader(string)
|
loader = importlib.find_loader(string)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
# See #491. Importlib might raise a ValueError, to avoid this, we
|
# See #491. Importlib might raise a ValueError, to avoid this, we
|
||||||
|
|||||||
Reference in New Issue
Block a user