From dbc7881e36fa67d4ae648c1f55f96a43850de557 Mon Sep 17 00:00:00 2001 From: Florence Blanc-Renaud Date: Wed, 9 Sep 2020 09:24:46 +0200 Subject: [PATCH] dnsforwardzone-add: support dnspython 2.0 The command dnsforwardzone-add is assuming that the dns.rrset.RRset type stores "items" as a list. With dnspython 2.0 this is not true as a dict is used instead. As a consequence, in order to get the first record, it is not possible to use items[0]. As dict and list are both iterables, next(iter(items)) can be used in order to be compatible with dnspython 1.16 and 2.0. Fixes: https://pagure.io/freeipa/issue/8481 Reviewed-By: Alexander Bokovoy Reviewed-By: Rob Crittenden --- ipaserver/plugins/dns.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipaserver/plugins/dns.py b/ipaserver/plugins/dns.py index 919402db1..7130f8f7d 100644 --- a/ipaserver/plugins/dns.py +++ b/ipaserver/plugins/dns.py @@ -4313,7 +4313,7 @@ class dnsforwardzone(DNSZoneBase): except dns.exception.DNSException: continue else: - ipa_dns_ip = str(ans.rrset.items[0]) + ipa_dns_ip = str(next(iter(ans.rrset.items))) break if not ipa_dns_ip: