Changes in anticipation of stricter str vs. bytes enforcement.

This commit is contained in:
Guido van Rossum 2007-08-27 17:25:39 +00:00
parent 39478e8528
commit 6dab795351
3 changed files with 5 additions and 5 deletions

View File

@ -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')

View File

@ -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"""

View File

@ -176,7 +176,7 @@ class DumbXMLWriter:
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"""\
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
"""
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)