Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / python-modules / sleekxmpp / dnspython-ip6.patch
blobd8d6eb1068387dc4ff86d16cab6db200ba22664d
1 --- a/sleekxmpp/xmlstream/resolver.py
2 +++ b/sleekxmpp/xmlstream/resolver.py
3 @@ -175,6 +175,9 @@ def get_A(host, resolver=None, use_dnspy
4 """
5 log.debug("DNS: Querying %s for A records." % host)
7 + if isinstance(host, bytes):
8 + host = host.decode("utf-8")
10 # If not using dnspython, attempt lookup using the OS level
11 # getaddrinfo() method.
12 if resolver is None or not use_dnspython:
13 @@ -189,7 +192,10 @@ def get_A(host, resolver=None, use_dnspy
14 # Using dnspython:
15 try:
16 recs = resolver.query(host, dns.rdatatype.A)
17 - return [rec.to_text() for rec in recs]
18 + if isinstance(recs[0].to_text(), bytes):
19 + return [rec.to_text().decode("utf-8") for rec in recs]
20 + else:
21 + return [rec.to_text() for rec in recs]
22 except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
23 log.debug("DNS: No A records for %s" % host)
24 return []
25 @@ -222,6 +228,9 @@ def get_AAAA(host, resolver=None, use_dn
26 """
27 log.debug("DNS: Querying %s for AAAA records." % host)
29 + if isinstance(host, bytes):
30 + host = host.decode("utf-8")
32 # If not using dnspython, attempt lookup using the OS level
33 # getaddrinfo() method.
34 if resolver is None or not use_dnspython:
35 @@ -240,7 +249,10 @@ def get_AAAA(host, resolver=None, use_dn
36 # Using dnspython:
37 try:
38 recs = resolver.query(host, dns.rdatatype.AAAA)
39 - return [rec.to_text() for rec in recs]
40 + if isinstance(recs[0].to_text(), bytes):
41 + return [rec.to_text().decode("utf-8") for rec in recs]
42 + else:
43 + return [rec.to_text() for rec in recs]
44 except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
45 log.debug("DNS: No AAAA records for %s" % host)
46 return []
47 @@ -324,6 +336,8 @@ def get_SRV(host, port, service, proto='
48 if running_sum >= selected:
49 rec = sums[running_sum]
50 host = rec.target.to_text()
51 + if isinstance(host, bytes):
52 + host = host.decode("utf-8")
53 if host.endswith('.'):
54 host = host[:-1]
55 sorted_recs.append((host, rec.port))