pythonPackages.sleekxmpp: fix dnspython issue
This commit is contained in:
parent
bf2e512377
commit
6f76d907c8
23
pkgs/development/python-modules/sleekxmpp/default.nix
Normal file
23
pkgs/development/python-modules/sleekxmpp/default.nix
Normal file
@ -0,0 +1,23 @@
|
||||
{ stdenv, fetchurl, buildPythonPackage, dns, pyasn1 }:
|
||||
|
||||
buildPythonPackage rec {
|
||||
name = "sleekxmpp-${version}";
|
||||
version = "1.3.1";
|
||||
|
||||
propagatedBuildInputs = [ dns pyasn1 ];
|
||||
|
||||
patches = [
|
||||
./dnspython-ip6.patch
|
||||
];
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://pypi/s/sleekxmpp/${name}.tar.gz";
|
||||
sha256 = "1krkhkvj8xw5a6c2xlf7h1rg9xdcm9d8x2niivwjahahpvbl6krr";
|
||||
};
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "XMPP library for Python";
|
||||
license = licenses.mit;
|
||||
homepage = "http://sleekxmpp.com/";
|
||||
};
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
--- a/sleekxmpp/xmlstream/resolver.py
|
||||
+++ b/sleekxmpp/xmlstream/resolver.py
|
||||
@@ -175,6 +175,9 @@ def get_A(host, resolver=None, use_dnspy
|
||||
"""
|
||||
log.debug("DNS: Querying %s for A records." % host)
|
||||
|
||||
+ if isinstance(host, bytes):
|
||||
+ host = host.decode("utf-8")
|
||||
+
|
||||
# If not using dnspython, attempt lookup using the OS level
|
||||
# getaddrinfo() method.
|
||||
if resolver is None or not use_dnspython:
|
||||
@@ -189,7 +192,10 @@ def get_A(host, resolver=None, use_dnspy
|
||||
# Using dnspython:
|
||||
try:
|
||||
recs = resolver.query(host, dns.rdatatype.A)
|
||||
- return [rec.to_text() for rec in recs]
|
||||
+ if isinstance(recs[0].to_text(), bytes):
|
||||
+ return [rec.to_text().decode("utf-8") for rec in recs]
|
||||
+ else:
|
||||
+ return [rec.to_text() for rec in recs]
|
||||
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
|
||||
log.debug("DNS: No A records for %s" % host)
|
||||
return []
|
||||
@@ -222,6 +228,9 @@ def get_AAAA(host, resolver=None, use_dn
|
||||
"""
|
||||
log.debug("DNS: Querying %s for AAAA records." % host)
|
||||
|
||||
+ if isinstance(host, bytes):
|
||||
+ host = host.decode("utf-8")
|
||||
+
|
||||
# If not using dnspython, attempt lookup using the OS level
|
||||
# getaddrinfo() method.
|
||||
if resolver is None or not use_dnspython:
|
||||
@@ -240,7 +249,10 @@ def get_AAAA(host, resolver=None, use_dn
|
||||
# Using dnspython:
|
||||
try:
|
||||
recs = resolver.query(host, dns.rdatatype.AAAA)
|
||||
- return [rec.to_text() for rec in recs]
|
||||
+ if isinstance(recs[0].to_text(), bytes):
|
||||
+ return [rec.to_text().decode("utf-8") for rec in recs]
|
||||
+ else:
|
||||
+ return [rec.to_text() for rec in recs]
|
||||
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
|
||||
log.debug("DNS: No AAAA records for %s" % host)
|
||||
return []
|
||||
@@ -324,6 +336,8 @@ def get_SRV(host, port, service, proto='
|
||||
if running_sum >= selected:
|
||||
rec = sums[running_sum]
|
||||
host = rec.target.to_text()
|
||||
+ if isinstance(host, bytes):
|
||||
+ host = host.decode("utf-8")
|
||||
if host.endswith('.'):
|
||||
host = host[:-1]
|
||||
sorted_recs.append((host, rec.port))
|
Loading…
Reference in New Issue
Block a user