From 19b440424ae1005d7278c2e8388ef5337af6cb90 Mon Sep 17 00:00:00 2001 From: Casey Deccio Date: Fri, 24 Jun 2016 20:51:54 -0400 Subject: [PATCH] Fix dns.name.Name.to_text() Fix dns.name.Name.to_text(), so root is displayed properly. --- dns/name.py | 2 +- tests/test_name.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dns/name.py b/dns/name.py index 5d017a35..c30e58e0 100644 --- a/dns/name.py +++ b/dns/name.py @@ -387,7 +387,7 @@ class Name(object): if len(self.labels) == 0: return u'@' - if len(self.labels) == 1 and self.labels[0] == '': + if len(self.labels) == 1 and self.labels[0] == b'': return u'.' if omit_final_dot and self.is_absolute(): l = self.labels[:-1] diff --git a/tests/test_name.py b/tests/test_name.py index 645cf759..581459ac 100644 --- a/tests/test_name.py +++ b/tests/test_name.py @@ -242,6 +242,14 @@ class NameTestCase(unittest.TestCase): t = n.to_text() self.assertEqual(t, br'x80\.bar') + def testToText10(self): + t = dns.name.empty.to_unicode() + self.assertEqual(t, '@') + + def testToText11(self): + t = dns.name.root.to_unicode() + self.assertEqual(t, '.') + def testSlice1(self): n = dns.name.from_text(r'a.b.c.', origin=None) s = n[:] -- 2.47.3