mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-11 09:08:32 +02:00
Catch proper exceptions in python3.4
This commit is contained in:
parent
378baf17a1
commit
7b2c47cbbe
1 changed files with 5 additions and 1 deletions
|
@ -17,6 +17,10 @@ from xml.parsers.expat import ExpatError
|
|||
|
||||
class DayOne(Journal.Journal):
|
||||
"""A special Journal handling DayOne files"""
|
||||
|
||||
# InvalidFileException was added to plistlib in Python3.4
|
||||
PLIST_EXCEPTIONS = (ExpatError, plistlib.InvalidFileException) if hasattr(plistlib, "InvalidFileException") else ExpatError
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.entries = []
|
||||
self._deleted_entries = []
|
||||
|
@ -29,7 +33,7 @@ class DayOne(Journal.Journal):
|
|||
with open(filename, 'rb') as plist_entry:
|
||||
try:
|
||||
dict_entry = plistlib.readPlist(plist_entry)
|
||||
except ExpatError:
|
||||
except self.PLIST_EXCEPTIONS:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue