[Python-checkins] python/dist/src/Lib/plat-mac plistlib.py,1.2,1.3
jvr@users.sourceforge.net
jvr@users.sourceforge.net
Tue, 01 Jul 2003 13:15:40 -0700
Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv22839
Modified Files:
plistlib.py
Log Message:
- replaced a couple of asserts with proper exceptions
- use isinstance instead of flaky file-detection code
Index: plistlib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/plistlib.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** plistlib.py 9 Apr 2003 13:25:43 -0000 1.2
--- plistlib.py 1 Jul 2003 20:15:38 -0000 1.3
***************
*** 143,147 ****
self.writeArray(value)
else:
! assert 0, "unsuported type: %s" % type(value)
def writeData(self, data):
--- 143,147 ----
self.writeArray(value)
else:
! raise TypeError("unsuported type: %s" % type(value))
def writeData(self, data):
***************
*** 157,161 ****
items.sort()
for key, value in items:
! assert isinstance(key, (str, unicode)), "keys must be strings"
self.simpleElement("key", key)
self.writeValue(value)
--- 157,162 ----
items.sort()
for key, value in items:
! if not isinstance(key, (str, unicode)):
! raise TypeError("keys must be strings")
self.simpleElement("key", key)
self.writeValue(value)
***************
*** 205,209 ****
def fromFile(cls, pathOrFile):
didOpen = 0
! if not hasattr(pathOrFile, "write"):
pathOrFile = open(pathOrFile)
didOpen = 1
--- 206,210 ----
def fromFile(cls, pathOrFile):
didOpen = 0
! if isinstance(pathOrFile, (str, unicode)):
pathOrFile = open(pathOrFile)
didOpen = 1
***************
*** 216,220 ****
def write(self, pathOrFile):
! if not hasattr(pathOrFile, "write"):
pathOrFile = open(pathOrFile, "w")
didOpen = 1
--- 217,221 ----
def write(self, pathOrFile):
! if isinstance(pathOrFile, (str, unicode)):
pathOrFile = open(pathOrFile, "w")
didOpen = 1