From 6dab79535139a36d7e845c1c5f399d7a59d5d630 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 27 Aug 2007 17:25:39 +0000 Subject: [PATCH] Changes in anticipation of stricter str vs. bytes enforcement. --- Lib/plat-mac/Carbon/AppleEvents.py | 2 +- Lib/plat-mac/aetypes.py | 2 +- Lib/plat-mac/plistlib.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/plat-mac/Carbon/AppleEvents.py b/Lib/plat-mac/Carbon/AppleEvents.py index 33ee3b3d087..ec19d19c2bc 100644 --- a/Lib/plat-mac/Carbon/AppleEvents.py +++ b/Lib/plat-mac/Carbon/AppleEvents.py @@ -1,6 +1,6 @@ # Generated from 'AEDataModel.h' -def FOUR_CHAR_CODE(x): return bytes(x) +def FOUR_CHAR_CODE(x): return x.encode("latin-1") typeBoolean = FOUR_CHAR_CODE('bool') typeChar = FOUR_CHAR_CODE('TEXT') typeSInt16 = FOUR_CHAR_CODE('shor') diff --git a/Lib/plat-mac/aetypes.py b/Lib/plat-mac/aetypes.py index b4492edc441..cf6e3b940ce 100644 --- a/Lib/plat-mac/aetypes.py +++ b/Lib/plat-mac/aetypes.py @@ -22,7 +22,7 @@ def _four_char_code(four_chars): four_chars must contain only ASCII characters. """ - return bytes("%-4.4s" % str(four_chars)) + return ("%-4.4s" % str(four_chars)).encode("latin-1") class Unknown: """An uninterpreted AE object""" diff --git a/Lib/plat-mac/plistlib.py b/Lib/plat-mac/plistlib.py index ca7ac873cd5..a107b26a7e4 100644 --- a/Lib/plat-mac/plistlib.py +++ b/Lib/plat-mac/plistlib.py @@ -176,7 +176,7 @@ def writeln(self, line): line = line.encode('utf-8') self.file.write(self.indentLevel * self.indent) self.file.write(line) - self.file.write('\n') + self.file.write(b'\n') # Contents should conform to a subset of ISO 8601 @@ -220,14 +220,14 @@ def _escapeAndEncode(text): return text.encode("utf-8") # encode as UTF-8 -PLISTHEADER = """\ +PLISTHEADER = b"""\ """ class PlistWriter(DumbXMLWriter): - def __init__(self, file, indentLevel=0, indent="\t", writeHeader=1): + def __init__(self, file, indentLevel=0, indent=b"\t", writeHeader=1): if writeHeader: file.write(PLISTHEADER) DumbXMLWriter.__init__(self, file, indentLevel, indent)