Skip to content
Prev Previous commit
Next Next commit
Improve comparisons in _infer_subtype
  • Loading branch information
JosephSBoyle committed Mar 9, 2023
commit 3561ee9f6f563ea75553f90cc6d687d852b6b051
4 changes: 2 additions & 2 deletions Lib/email/mime/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def __init__(self, _audiodata, _subtype=None,


def _infer_subtype(h: bytes) -> str:
"""Infer the audio format based on the data's header"""
if h.startswith(b'FORM') and h[8:12] in (b'AIFC', b'AIFF'):
return 'x-aiff'
elif h.startswith(b'.snd'):
return 'basic'
elif h.startswith(b'RIFF') and h[8:12] == b'WAVE' and h[12:16] == b'fmt ':
# 'RIFF' <len> 'WAVE' 'fmt ' <len>
elif h.startswith(b'RIFF') and h[8:16] == b'WAVEfmt ':
return 'x-wav'

raise TypeError('Could not find audio MIME subtype')