From 523b6a43433f98379a574286a841a3087954226f Mon Sep 17 00:00:00 2001 From: Nicolas Bases Date: Fri, 6 Jan 2023 21:14:46 +0100 Subject: [PATCH] Fix issue when dateparser.parse returns None It is possible for dateparser.parse method to return None and when this happens we are comparing a None against a datetime raising an exception. This is only possible right now because there is a bug in the dateparser code that is not recognizing "Mon" as "Monday". --- memorious/logic/http.py | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/memorious/logic/http.py b/memorious/logic/http.py index 511b4ca..abbc210 100644 --- a/memorious/logic/http.py +++ b/memorious/logic/http.py @@ -253,6 +253,9 @@ def last_modified(self): if last_modified_header is not None: # Tue, 15 Nov 1994 12:45:26 GMT last_modified = parse_date(last_modified_header) + if last_modified is None: + return None + if last_modified < now + timedelta(seconds=30): return last_modified.strftime("%Y-%m-%dT%H:%M:%S%z") return None diff --git a/setup.py b/setup.py index 51b71f8..8d577f4 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="memorious", - version="2.5.0", + version="2.5.1", description="A minimalistic, recursive web crawling library for Python.", long_description="", classifiers=[