[ldns-users] Python3 / ldns_wire2pkt
Christoph Egger
christoph at christoph-egger.org
Tue Aug 30 15:06:46 UTC 2016
Hi!
For ldns.ldns_wire2pkt to work with Python3 one needs it to accept a
python byte object instead of a string. After a lot of fiddling around
the below patch seems to make it work. However iterationg [2] over rrs()
fails with [1] -- extracting the first one works fine.
[0]
--- ldns-1.6.17.orig/contrib/python/ldns.i
+++ ldns-1.6.17/contrib/python/ldns.i
@@ -132,12 +137,22 @@ uint32_t ldns_read_timeval_usec(struct t
%apply uint32_t *OUTPUT { uint32_t *default_ttl};
+#define SWIG_PYTHON_STRICT_BYTE_CHAR
+
// wire2pkt
-%apply (char *STRING, int LENGTH) { (const char *str, int len) };
+// %apply (char *STRING, int LENGTH) { (const char *str, int len) };
+
+%typemap(in) (const char* str,int len) (Py_ssize_t lenn) %{
+ if(PyBytes_AsStringAndSize($input,&$1,&lenn) == -1)
+ return NULL;
+ $2 = (int)lenn;
+%}
+
[1]
StopIteration
During handling of the above exception, another exception occurred:
SystemError: <built-in function _ldns_rr_list_deep_free> returned a result with an error set
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./check_dnssec", line 107, in <module>
sys.exit(main())
File "./check_dnssec", line 104, in main
check_synced(resolver, zone, args)
File "./check_dnssec", line 62, in check_synced
LDNS_SECTION_ANSWER).rrs())
SystemError: <built-in function _ldns_rr_free> returned a result with an error set
[2]
list(result.rr_list_by_type(RR_TYPE_SOA, LDNS_SECTION_ANSWER).rrs())
--
9FED 5C6C E206 B70A 5857 70CA 9655 22B9 D49A E731
Debian Developer | Lisp Hacker | CaCert Assurer
More information about the ldns-users
mailing list