summaryrefslogtreecommitdiffstats
path: root/Lib/email/header.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/email/header.py')
-rw-r--r--Lib/email/header.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/email/header.py b/Lib/email/header.py
index e03e42d..786a71f 100644
--- a/Lib/email/header.py
+++ b/Lib/email/header.py
@@ -341,10 +341,11 @@ class _ValueFormatter:
self._current_line = _Accumulator(headerlen)
def __str__(self):
- # Remove the trailing TRANSITIONAL_SPACE
- last_line = self._current_line.pop()
- if last_line is not TRANSITIONAL_SPACE:
- self._current_line.push(last_line)
+ # Remove any trailing TRANSITIONAL_SPACE
+ if len(self._current_line) > 0:
+ last_line = self._current_line.pop()
+ if last_line is not TRANSITIONAL_SPACE:
+ self._current_line.push(last_line)
self.newline()
return NL.join(self._lines)