Skip to content

Commit 44c5f8c

Browse files
committed
Improve comparisons in _infer_subtype
The length of the slice was such that a comparison against a target string of bytes would never return True.
1 parent 209fc85 commit 44c5f8c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/email/mime/audio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ def __init__(self, _audiodata, _subtype=None,
4343

4444

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

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

0 commit comments

Comments
 (0)