Skip to content

Commit 9300a75

Browse files
committed
get_all(): We never returned failobj if we found no matching headers.
Fix that, and also make the docstring describe failobj.
1 parent 93a6327 commit 9300a75

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Lib/email/Message.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,16 @@ def get_all(self, name, failobj=None):
227227
These will be sorted in the order they appeared in the original
228228
message, and may contain duplicates. Any fields deleted and
229229
re-inserted are alwyas appended to the header list.
230+
231+
If no such fields exist, failobj is returned (defaults to None).
230232
"""
231233
values = []
232234
name = name.lower()
233235
for k, v in self._headers:
234236
if k.lower() == name:
235237
values.append(v)
238+
if not values:
239+
return failobj
236240
return values
237241

238242
def add_header(self, _name, _value, **_params):

0 commit comments

Comments
 (0)