From 7b2c47cbbe0e3276c07be2148d0b95663db1cc5a Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Thu, 22 May 2014 13:24:19 -0700 Subject: [PATCH] Catch proper exceptions in python3.4 --- jrnl/DayOneJournal.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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: