mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Salt no longer vendors six
Fixes #63874 Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
bbffd853f9
commit
dc9625699a
4 changed files with 2 additions and 59 deletions
1
changelog/63874.removed.md
Normal file
1
changelog/63874.removed.md
Normal file
|
@ -0,0 +1 @@
|
|||
Removed `SixRedirectImporter` from Salt. Salt hasn't shipped `six` since Salt 3004.
|
|
@ -42,26 +42,8 @@ class TornadoImporter:
|
|||
return None
|
||||
|
||||
|
||||
class SixRedirectImporter:
|
||||
def find_module(self, module_name, package_path=None):
|
||||
if module_name.startswith("salt.ext.six"):
|
||||
return self
|
||||
return None
|
||||
|
||||
def load_module(self, name):
|
||||
mod = importlib.import_module(name[9:])
|
||||
sys.modules[name] = mod
|
||||
return mod
|
||||
|
||||
def create_module(self, spec):
|
||||
return self.load_module(spec.name)
|
||||
|
||||
def exec_module(self, module):
|
||||
return None
|
||||
|
||||
|
||||
# Try our importer first
|
||||
sys.meta_path = [TornadoImporter(), SixRedirectImporter()] + sys.meta_path
|
||||
sys.meta_path = [TornadoImporter()] + sys.meta_path
|
||||
|
||||
|
||||
# All salt related deprecation warnings should be shown once each!
|
||||
|
|
|
@ -906,7 +906,6 @@ def gen_min(
|
|||
"salt/client/__init__.py",
|
||||
"salt/ext",
|
||||
"salt/ext/__init__.py",
|
||||
"salt/ext/six.py",
|
||||
"salt/ext/ipaddress.py",
|
||||
"salt/version.py",
|
||||
"salt/syspaths.py",
|
||||
|
|
|
@ -4,7 +4,6 @@ import subprocess
|
|||
import sys
|
||||
|
||||
import pytest
|
||||
import six # pylint: disable=blacklisted-external-import,3rd-party-module-not-gated
|
||||
|
||||
import salt
|
||||
|
||||
|
@ -44,44 +43,6 @@ def test_tornado_import_override(tmp_path):
|
|||
assert ret.stdout.strip() == "salt.ext.tornado"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"six_import_line,six_print_line",
|
||||
(
|
||||
("import salt.ext.six", "print(salt.ext.six.__name__, salt.ext.six.__file__)"),
|
||||
("import salt.ext.six as six", "print(six.__name__, six.__file__)"),
|
||||
("from salt.ext import six", "print(six.__name__, six.__file__)"),
|
||||
("import six", "print(six.__name__, six.__file__)"),
|
||||
),
|
||||
)
|
||||
def test_salt_ext_six_import_override(tmp_path, six_import_line, six_print_line):
|
||||
"""
|
||||
Ensure we are not using, the now non existent, vendor'ed six
|
||||
"""
|
||||
test_source = """
|
||||
import salt
|
||||
{}
|
||||
{}
|
||||
""".format(
|
||||
six_import_line, six_print_line
|
||||
)
|
||||
with pytest.helpers.temp_file(
|
||||
"test.py", directory=tmp_path, contents=test_source
|
||||
) as test_source_path:
|
||||
env = os.environ.copy()
|
||||
env["PYTHONPATH"] = os.pathsep.join(sys.path)
|
||||
ret = subprocess.run(
|
||||
[sys.executable, str(test_source_path)],
|
||||
stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
env=env,
|
||||
shell=False,
|
||||
check=False,
|
||||
universal_newlines=True,
|
||||
)
|
||||
assert ret.returncode == 0
|
||||
assert ret.stdout.strip() == "six {}".format(six.__file__)
|
||||
|
||||
|
||||
def test_regression_56063():
|
||||
importer = salt.TornadoImporter()
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue