mirror of
https://github.com/python/cpython.git
synced 2025-12-11 11:31:05 +00:00
gh-102542 Remove unused bytes object and bytes slicing (#106433)
Remove unused bytes object and bytes slicing Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
parent
12a9813808
commit
70e2a42647
1 changed files with 4 additions and 7 deletions
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
__all__ = ['MIMEAudio']
|
__all__ = ['MIMEAudio']
|
||||||
|
|
||||||
from io import BytesIO
|
|
||||||
from email import encoders
|
from email import encoders
|
||||||
from email.mime.nonmultipart import MIMENonMultipart
|
from email.mime.nonmultipart import MIMENonMultipart
|
||||||
|
|
||||||
|
|
@ -59,10 +58,8 @@ def _what(data):
|
||||||
# sndhdr.what() had a pretty cruddy interface, unfortunately. This is why
|
# sndhdr.what() had a pretty cruddy interface, unfortunately. This is why
|
||||||
# we re-do it here. It would be easier to reverse engineer the Unix 'file'
|
# we re-do it here. It would be easier to reverse engineer the Unix 'file'
|
||||||
# command and use the standard 'magic' file, as shipped with a modern Unix.
|
# command and use the standard 'magic' file, as shipped with a modern Unix.
|
||||||
hdr = data[:512]
|
|
||||||
fakefile = BytesIO(hdr)
|
|
||||||
for testfn in _rules:
|
for testfn in _rules:
|
||||||
if res := testfn(hdr, fakefile):
|
if res := testfn(data):
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
@ -74,7 +71,7 @@ def rule(rulefunc):
|
||||||
|
|
||||||
|
|
||||||
@rule
|
@rule
|
||||||
def _aiff(h, f):
|
def _aiff(h):
|
||||||
if not h.startswith(b'FORM'):
|
if not h.startswith(b'FORM'):
|
||||||
return None
|
return None
|
||||||
if h[8:12] in {b'AIFC', b'AIFF'}:
|
if h[8:12] in {b'AIFC', b'AIFF'}:
|
||||||
|
|
@ -84,7 +81,7 @@ def _aiff(h, f):
|
||||||
|
|
||||||
|
|
||||||
@rule
|
@rule
|
||||||
def _au(h, f):
|
def _au(h):
|
||||||
if h.startswith(b'.snd'):
|
if h.startswith(b'.snd'):
|
||||||
return 'basic'
|
return 'basic'
|
||||||
else:
|
else:
|
||||||
|
|
@ -92,7 +89,7 @@ def _au(h, f):
|
||||||
|
|
||||||
|
|
||||||
@rule
|
@rule
|
||||||
def _wav(h, f):
|
def _wav(h):
|
||||||
# 'RIFF' <len> 'WAVE' 'fmt ' <len>
|
# 'RIFF' <len> 'WAVE' 'fmt ' <len>
|
||||||
if not h.startswith(b'RIFF') or h[8:12] != b'WAVE' or h[12:16] != b'fmt ':
|
if not h.startswith(b'RIFF') or h[8:12] != b'WAVE' or h[12:16] != b'fmt ':
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue