[GNOME-ABRT PATCH] Recover from invalid time stamp values
Jakub Filak
jfilak at redhat.com
Fri Aug 9 07:41:39 UTC 2013
Closes rhbz#995337
Signed-off-by: Jakub Filak <jfilak at redhat.com>
---
src/gnome_abrt/problems.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/gnome_abrt/problems.py b/src/gnome_abrt/problems.py
index db1064e..c8ad175 100644
--- a/src/gnome_abrt/problems.py
+++ b/src/gnome_abrt/problems.py
@@ -146,18 +146,26 @@ class Problem:
return items
def __getitem__(self, item, cached=True):
+ def datetime_from_stamp(stamp):
+ try:
+ return datetime.datetime.fromtimestamp(float(stamp))
+ except TypeError:
+ raise InvalidProblem(self.problem_id, "Empty time stamp")
+ except ValueError:
+ raise InvalidProblem(self.problem_id, "Invalid value in time stamp")
+
if self.data is None:
# Load initial problem data into cache
self.__loaditems__(*Problem.INITIAL_ELEMENTS)
if item == 'date':
- return datetime.datetime.fromtimestamp(float(self['time']))
+ return datetime_from_stamp(self['time'])
if item == 'date_last':
last_ocr = self['last_occurrence']
if last_ocr:
- return datetime.datetime.fromtimestamp(float(last_ocr))
+ return datetime_from_stamp(last_ocr)
else:
- return datetime.datetime.fromtimestamp(float(self['time']))
+ return datetime_from_stamp(self['time'])
elif item == 'application':
return self.get_application()
elif item == 'is_reported':
--
1.8.3.1
More information about the Crash-catcher
mailing list