From ba25c8991934c29bde4d1e5f8c45521414300b4f Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 31 Aug 2007 14:18:20 +0000 Subject: Got test_plistlib working. Don't ask how. --- Lib/plat-mac/plistlib.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/plat-mac/plistlib.py b/Lib/plat-mac/plistlib.py index 2a7957e..e0e01ff 100644 --- a/Lib/plat-mac/plistlib.py +++ b/Lib/plat-mac/plistlib.py @@ -260,9 +260,9 @@ class PlistWriter(DumbXMLWriter): def writeData(self, data): self.beginElement("data") self.indentLevel -= 1 - maxlinelength = 76 - len(self.indent.replace("\t", " " * 8) * + maxlinelength = 76 - len(self.indent.replace(b"\t", b" " * 8) * self.indentLevel) - for line in data.asBase64(maxlinelength).split("\n"): + for line in data.asBase64(maxlinelength).split(b"\n"): if line: self.writeln(line) self.indentLevel += 1 @@ -368,11 +368,11 @@ class Data: raise TypeError("data must be as bytes") self.data = data + @classmethod def fromBase64(cls, data): # base64.decodestring just calls binascii.a2b_base64; # it seems overkill to use both base64 and binascii. return cls(binascii.a2b_base64(data)) - fromBase64 = classmethod(fromBase64) def asBase64(self, maxlinelength=76): return _encodeBase64(self.data, maxlinelength) @@ -464,6 +464,6 @@ class PlistParser: def end_string(self): self.addObject(self.getData()) def end_data(self): - self.addObject(Data.fromBase64(self.getData())) + self.addObject(Data.fromBase64(self.getData().encode("utf-8"))) def end_date(self): self.addObject(_dateFromString(self.getData())) -- cgit v0.12