pythonPackages.sleekxmpp: fix dnspython issue

+78
+23
pkgs/development/python-modules/sleekxmpp/default.nix
··· 1 + { stdenv, fetchurl, buildPythonPackage, dns, pyasn1 }: 2 + 3 + buildPythonPackage rec { 4 + name = "sleekxmpp-${version}"; 5 + version = "1.3.1"; 6 + 7 + propagatedBuildInputs = [ dns pyasn1 ]; 8 + 9 + patches = [ 10 + ./dnspython-ip6.patch 11 + ]; 12 + 13 + src = fetchurl { 14 + url = "mirror://pypi/s/sleekxmpp/${name}.tar.gz"; 15 + sha256 = "1krkhkvj8xw5a6c2xlf7h1rg9xdcm9d8x2niivwjahahpvbl6krr"; 16 + }; 17 + 18 + meta = with stdenv.lib; { 19 + description = "XMPP library for Python"; 20 + license = licenses.mit; 21 + homepage = "http://sleekxmpp.com/"; 22 + }; 23 + }
+55
pkgs/development/python-modules/sleekxmpp/dnspython-ip6.patch
··· 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) 6 + 7 + + if isinstance(host, bytes): 8 + + host = host.decode("utf-8") 9 + + 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) 28 + 29 + + if isinstance(host, bytes): 30 + + host = host.decode("utf-8") 31 + + 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))