From 5fbea6202fc2d0e7d348703ad7dde3897ba06c2b Mon Sep 17 00:00:00 2001 From: Talha Mansoor Date: Sun, 10 Nov 2013 01:38:44 +0500 Subject: [PATCH] Check argument type in get_date utility function before processing it Sitemap plugin calls this method to convert `modified` metadate into datetime. Depending on the version of Pelican `modified` can be string or a datetime object. Therefore get_date should check for the type of argument otherwise Pelican fails with a critical error. --- pelican/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pelican/utils.py b/pelican/utils.py index 4b25ec7f..2e315c3d 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -180,6 +180,8 @@ def get_date(string): If no format matches the given date, raise a ValueError. """ + if isinstance(string, datetime): + return string string = re.sub(' +', ' ', string) formats = [ # ISO 8601