aboutsummaryrefslogtreecommitdiff
path: root/b4/__init__.py
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-11-30 17:59:23 -0500
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-12-01 10:38:45 -0500
commit2f37e6f8e1401c7976f1f5f48bea404fe0e46af0 (patch)
treee7b273e972ccef4050e481aa8b73113afb083c4d /b4/__init__.py
parentf7426e9862c99f72931581671e59d4ba1e630a0a (diff)
downloadb4-2f37e6f8e1401c7976f1f5f48bea404fe0e46af0.tar.gz
Fix headers generated by "b4 ty"
Make sure we always create a Date: header, and that we're not crashing when we try to parse a message without a Date: header. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Diffstat (limited to 'b4/__init__.py')
-rw-r--r--b4/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/b4/__init__.py b/b4/__init__.py
index e7b27cd..c77ca9a 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -833,7 +833,12 @@ class LoreMessage:
except IndexError:
pass
- self.date = email.utils.parsedate_to_datetime(str(self.msg['Date']))
+ msgdate = self.msg.get('Date')
+ if msgdate:
+ self.date = email.utils.parsedate_to_datetime(str(msgdate))
+ else:
+ # An email without a Date: field?
+ self.date = datetime.datetime.now()
diffre = re.compile(r'^(---.*\n\+\+\+|GIT binary patch|diff --git \w/\S+ \w/\S+)', re.M | re.I)
diffstatre = re.compile(r'^\s*\d+ file.*\d+ (insertion|deletion)', re.M | re.I)