From 4c5e18bfd092d9003d12c89131f787a57d54cf38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Tue, 15 Sep 2020 17:05:13 +0200 Subject: [PATCH] IPv6AddressScoped: define self._scope_id for python3.9+ compatibility Example of trace: Traceback (most recent call last): File "/var/tmp/.root_dd8a91_salt/salt-call", line 27, in salt_call() File "/var/tmp/.root_dd8a91_salt/pyall/salt/scripts.py", line 472, in salt_call client.run() File "/var/tmp/.root_dd8a91_salt/pyall/salt/cli/call.py", line 48, in run caller = salt.cli.caller.Caller.factory(self.config) File "/var/tmp/.root_dd8a91_salt/pyall/salt/cli/caller.py", line 64, in factory return ZeroMQCaller(opts, **kwargs) File "/var/tmp/.root_dd8a91_salt/pyall/salt/cli/caller.py", line 329, in __init__ super(ZeroMQCaller, self).__init__(opts) File "/var/tmp/.root_dd8a91_salt/pyall/salt/cli/caller.py", line 89, in __init__ self.minion = salt.minion.SMinion(opts) File "/var/tmp/.root_dd8a91_salt/pyall/salt/minion.py", line 912, in __init__ opts["grains"] = salt.loader.grains(opts) File "/var/tmp/.root_dd8a91_salt/pyall/salt/loader.py", line 825, in grains ret = funcs[key]() File "/var/tmp/.root_dd8a91_salt/pyall/salt/grains/core.py", line 2369, in ip_fqdn ret["ipv6"] = salt.utils.network.ip_addrs6(include_loopback=True) File "/var/tmp/.root_dd8a91_salt/pyall/salt/utils/network.py", line 1353, in ip_addrs6 return _ip_addrs(interface, include_loopback, interface_data, "inet6") File "/var/tmp/.root_dd8a91_salt/pyall/salt/utils/network.py", line 1333, in _ip_addrs ret.add(addr) File "/usr/lib64/python3.9/ipaddress.py", line 1920, in __hash__ return hash((self._ip, self._scope_id)) AttributeError: _scope_id --- salt/_compat.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/salt/_compat.py b/salt/_compat.py index 491233b59e70..6882e43c0512 100644 --- a/salt/_compat.py +++ b/salt/_compat.py @@ -162,6 +162,9 @@ def __init__(self, address): else: self.__scope = None + # For compatibility with python3.9 ipaddress + self._scope_id = self.__scope + if sys.version_info.major == 2: ipaddress._BaseAddress.__init__(self, address) ipaddress._BaseV6.__init__(self, address)