Skip to content

Commit

Permalink
Fix refactoring bug when readPlist encounters an error
Browse files Browse the repository at this point in the history
  • Loading branch information
gregneagle committed Jan 7, 2014
1 parent ab48023 commit a6be44c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Code/FoundationPlist/FoundationPlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def _dataToPlist(data):
NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(
data, NSPropertyListMutableContainersAndLeaves, None, None))
if error:
errmsg = u"%s in file %s" % (error, filepath)
raise NSPropertyListSerializationException(errmsg)
raise NSPropertyListSerializationException(error)
else:
return plistObject

Expand All @@ -108,7 +107,12 @@ def _plistToData(plistObject):
def readPlist(filepath):
'''Read a .plist file from filepath. Return the unpacked root object
(which is usually a dictionary).'''
data = NSData.dataWithContentsOfFile_(filepath)
try:
data = NSData.dataWithContentsOfFile_(filepath)
except NSPropertyListSerializationException, error:
# insert filepath info into error message
errmsg = (u'%s in %s' % (error, filepath))
raise NSPropertyListSerializationException(errmsg)
return _dataToPlist(data)


Expand Down

0 comments on commit a6be44c

Please sign in to comment.