From: Bob Halley Date: Tue, 15 Nov 2016 14:05:49 +0000 (-0800) Subject: Fix trailing 0 suppression bug reintroduced in py2/py3 merge, and do not break py2... X-Git-Tag: v1.16.0~123 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82857a6481e67dd58606dacaecc2d4822d27c1a8;p=thirdparty%2Fdnspython.git Fix trailing 0 suppression bug reintroduced in py2/py3 merge, and do not break py2 either! --- diff --git a/dns/_compat.py b/dns/_compat.py index 956f9a13..e78b2883 100644 --- a/dns/_compat.py +++ b/dns/_compat.py @@ -19,6 +19,8 @@ if sys.version_info > (3,): return x.decode() def maybe_encode(x): return x.encode() + def maybe_chr(x): + return x else: text_type = unicode # pylint: disable=unicode-builtin, undefined-variable binary_type = str @@ -30,6 +32,8 @@ else: return x def maybe_encode(x): return x + def maybe_chr(x): + return chr(x) def round_py2_compat(what): diff --git a/dns/rdtypes/IN/APL.py b/dns/rdtypes/IN/APL.py index 82531688..2bd4ce5a 100644 --- a/dns/rdtypes/IN/APL.py +++ b/dns/rdtypes/IN/APL.py @@ -20,7 +20,7 @@ import dns.exception import dns.inet import dns.rdata import dns.tokenizer -from dns._compat import xrange +from dns._compat import xrange, maybe_chr class APLItem(object): @@ -63,7 +63,7 @@ class APLItem(object): # last = 0 for i in xrange(len(address) - 1, -1, -1): - if address[i] != 0: + if address[i] != maybe_chr(0): last = i + 1 break address = address[0: last]