From 10a6554c81144671e0e707d121c5381d8d87fb97 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 21 Jan 2021 12:41:56 -0600 Subject: [PATCH] Some chromagnon cache keys aren't bytes or text? --- fanficfare/chromagnon/cacheEntry.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fanficfare/chromagnon/cacheEntry.py b/fanficfare/chromagnon/cacheEntry.py index 47244dae..01eda589 100644 --- a/fanficfare/chromagnon/cacheEntry.py +++ b/fanficfare/chromagnon/cacheEntry.py @@ -108,10 +108,18 @@ class CacheEntry(): # It is probably an HTTP header self.key = cacheData.CacheData(addr, self.keyLength, True) - # Some keys seem to be '_dk_http://example.com https://example.com https://www.example.com/full/url/path' - # fix those up so the actual URL will work as a hash key in our table - # if key has whitespace followed by final http[s]://something, substitute, otherwise this leaves it unchanged - self.key = re.sub(r'^.*\s(https?://\S+)$', r'\1', self.key) + try: + # Some keys seem to be '_dk_http://example.com https://example.com https://www.example.com/full/url/path' + # fix those up so the actual URL will work as a hash key + # in our table if key has whitespace followed by final + # http[s]://something, substitute, otherwise this leaves + # it unchanged + self.key = re.sub(r'^.*\s(https?://\S+)$', r'\1', self.key) + except TypeError: + ## Some 'keys' are not bytes or text types. No idea why + ## not. + # print(self.key) + pass block.close() def keyToStr(self):