diff options
author | Manuel Ebert <manuel@1450.me> | 2014-05-22 13:24:19 -0700 |
---|---|---|
committer | Manuel Ebert <manuel@1450.me> | 2014-05-22 13:24:19 -0700 |
commit | 2948f6dc69b34f27f5ea84583466ec2466012069 (patch) | |
tree | 37360fa16506f3e616aabdea46878e5b41da4db4 | |
parent | 9265c3f85089ceb929a16a5992c7f6dfb4a680d8 (diff) |
Catch proper exceptions in python3.4
-rw-r--r-- | jrnl/DayOneJournal.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/jrnl/DayOneJournal.py b/jrnl/DayOneJournal.py index b3dbf0ea..d5649eb3 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -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: |