summaryrefslogtreecommitdiffstats
path: root/Lib/plat-mac
diff options
context:
space:
mode:
authorJust van Rossum <just@letterror.com>2003-07-01 20:15:38 (GMT)
committerJust van Rossum <just@letterror.com>2003-07-01 20:15:38 (GMT)
commit94af32e24494c849c603bd30320caa940b3f9bb0 (patch)
tree8e454a32039abdb97ac4bb84a4184829104adf6a /Lib/plat-mac
parent21d896cfa1646a1da4e0ead57db9defc2ade397c (diff)
downloadcpython-94af32e24494c849c603bd30320caa940b3f9bb0.zip
cpython-94af32e24494c849c603bd30320caa940b3f9bb0.tar.gz
cpython-94af32e24494c849c603bd30320caa940b3f9bb0.tar.bz2
- replaced a couple of asserts with proper exceptions
- use isinstance instead of flaky file-detection code
Diffstat (limited to 'Lib/plat-mac')
-rw-r--r--Lib/plat-mac/plistlib.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/plat-mac/plistlib.py b/Lib/plat-mac/plistlib.py
index 40e2675..1556d5f 100644
--- a/Lib/plat-mac/plistlib.py
+++ b/Lib/plat-mac/plistlib.py
@@ -142,7 +142,7 @@ class PlistWriter(DumbXMLWriter):
elif isinstance(value, (tuple, list)):
self.writeArray(value)
else:
- assert 0, "unsuported type: %s" % type(value)
+ raise TypeError("unsuported type: %s" % type(value))
def writeData(self, data):
self.beginElement("data")
@@ -156,7 +156,8 @@ class PlistWriter(DumbXMLWriter):
items = d.items()
items.sort()
for key, value in items:
- assert isinstance(key, (str, unicode)), "keys must be strings"
+ if not isinstance(key, (str, unicode)):
+ raise TypeError("keys must be strings")
self.simpleElement("key", key)
self.writeValue(value)
self.endElement("dict")
@@ -204,7 +205,7 @@ class Plist(Dict):
def fromFile(cls, pathOrFile):
didOpen = 0
- if not hasattr(pathOrFile, "write"):
+ if isinstance(pathOrFile, (str, unicode)):
pathOrFile = open(pathOrFile)
didOpen = 1
p = PlistParser()
@@ -215,7 +216,7 @@ class Plist(Dict):
fromFile = classmethod(fromFile)
def write(self, pathOrFile):
- if not hasattr(pathOrFile, "write"):
+ if isinstance(pathOrFile, (str, unicode)):
pathOrFile = open(pathOrFile, "w")
didOpen = 1
else: