]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
zone.to_text() should return a string. 431/head
authorBrian Wellington <bwelling@xbill.org>
Fri, 20 Mar 2020 20:58:02 +0000 (13:58 -0700)
committerBrian Wellington <bwelling@xbill.org>
Fri, 20 Mar 2020 20:58:02 +0000 (13:58 -0700)
As part of the Python 3 conversion, the result of dns.zone.to_text()
changed from str to bytes.  This was likely unintentional, as a method
with text in its name should be returning text.

dns/zone.py
tests/test_zone.py

index 0da4d89f4d325a4752ff29ae9a62db2e4e0ce18b..6b06ec2fe4fa4a837aa4b0b2ac1561601d1deb87 100644 (file)
@@ -22,7 +22,7 @@ from __future__ import generators
 import sys
 import re
 import os
-from io import BytesIO
+from io import StringIO
 
 import dns.exception
 import dns.name
@@ -553,7 +553,7 @@ class Zone(object):
         LF on POSIX, CRLF on Windows, CR on Macintosh).
         @type nl: string or None
         """
-        temp_buffer = BytesIO()
+        temp_buffer = StringIO()
         self.to_file(temp_buffer, sorted, relativize, nl)
         return_value = temp_buffer.getvalue()
         temp_buffer.close()
index 7e4a4d8fe92f607e4674d7cb5a30e825022f1d7d..d6de67247594bae83bce68e9e9b1136c2b5c263d 100644 (file)
@@ -242,8 +242,8 @@ class ZoneTestCase(unittest.TestCase):
         z = dns.zone.from_file(here('example'), 'example')
         ok = False
         try:
-            text_zone = z.to_text(nl=b'\x0a')
-            f = open(here('example3.out'), 'wb')
+            text_zone = z.to_text(nl='\x0a')
+            f = open(here('example3.out'), 'w')
             f.write(text_zone)
             f.close()
             ok = filecmp.cmp(here('example3.out'),