]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Fix trailing 0 suppression bug reintroduced in py2/py3 merge, and do not break py2...
authorBob Halley <halley@dnspython.org>
Tue, 15 Nov 2016 14:05:49 +0000 (06:05 -0800)
committerBob Halley <halley@dnspython.org>
Tue, 15 Nov 2016 14:05:49 +0000 (06:05 -0800)
dns/_compat.py
dns/rdtypes/IN/APL.py

index 956f9a13324c6354f2aefdb6a548bbd2fbabaa96..e78b2883efe5a867605e602e04302611c23f6afb 100644 (file)
@@ -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):
index 82531688f3ed302e678a98c7bd9dcdbb97ed0634..2bd4ce5a9e00938f935751159737f31057f50d0b 100644 (file)
@@ -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]