[ldns-users] Python3 / ldns_wire2pkt
Benno Overeinder
benno at NLnetLabs.nl
Tue Oct 18 07:06:44 UTC 2016
Hi Christoph,
We will pick-up your patch soon.
Best,
-- Benno
On 30/08/2016 17:06, Christoph Egger wrote:
> 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())
>
--
Benno J. Overeinder
NLnet Labs
http://www.nlnetlabs.nl/
More information about the ldns-users
mailing list