summaryrefslogtreecommitdiffstats
path: root/contrib/python/future/py3/patches/08-support-python-3.13.patch
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-07-21 12:37:15 +0300
committerrobot-piglet <[email protected]>2025-07-21 12:54:58 +0300
commitcaefbb016b70b186bad0fa7f07a1524b3211fec4 (patch)
treecc7f0d3f511d8d66cfe794fc3550bbe187901014 /contrib/python/future/py3/patches/08-support-python-3.13.patch
parentce2bac1786d54724a15f7211d5f1bf29d15af171 (diff)
Intermediate changes
commit_hash:0897b988c8ca7235b4f13624177866ac14a46fdd
Diffstat (limited to 'contrib/python/future/py3/patches/08-support-python-3.13.patch')
-rw-r--r--contrib/python/future/py3/patches/08-support-python-3.13.patch103
1 files changed, 103 insertions, 0 deletions
diff --git a/contrib/python/future/py3/patches/08-support-python-3.13.patch b/contrib/python/future/py3/patches/08-support-python-3.13.patch
new file mode 100644
index 00000000000..9b726f25e98
--- /dev/null
+++ b/contrib/python/future/py3/patches/08-support-python-3.13.patch
@@ -0,0 +1,103 @@
+--- contrib/python/future/py3/future/backports/email/mime/audio.py (index)
++++ contrib/python/future/py3/future/backports/email/mime/audio.py (working tree)
+@@ -9,37 +9,11 @@ from __future__ import absolute_import
+
+ __all__ = ['MIMEAudio']
+
+-import sndhdr
+-
+ from io import BytesIO
+ from future.backports.email import encoders
+ from future.backports.email.mime.nonmultipart import MIMENonMultipart
+
+
+-_sndhdr_MIMEmap = {'au' : 'basic',
+- 'wav' :'x-wav',
+- 'aiff':'x-aiff',
+- 'aifc':'x-aiff',
+- }
+-
+-# There are others in sndhdr that don't have MIME types. :(
+-# Additional ones to be added to sndhdr? midi, mp3, realaudio, wma??
+-def _whatsnd(data):
+- """Try to identify a sound file type.
+-
+- sndhdr.what() has a pretty cruddy interface, unfortunately. This is why
+- 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.
+- """
+- hdr = data[:512]
+- fakefile = BytesIO(hdr)
+- for testfn in sndhdr.tests:
+- res = testfn(hdr, fakefile)
+- if res is not None:
+- return _sndhdr_MIMEmap.get(res[0])
+- return None
+-
+-
+ class MIMEAudio(MIMENonMultipart):
+ """Class for generating audio/* MIME documents."""
+
+@@ -66,9 +40,61 @@ class MIMEAudio(MIMENonMultipart):
+ header.
+ """
+ if _subtype is None:
+- _subtype = _whatsnd(_audiodata)
++ _subtype = _what(_audiodata)
+ if _subtype is None:
+ raise TypeError('Could not find audio MIME subtype')
+ MIMENonMultipart.__init__(self, 'audio', _subtype, **_params)
+ self.set_payload(_audiodata)
+ _encoder(self)
++
++
++_rules = []
++
++
++# Originally from the sndhdr module.
++#
++# There are others in sndhdr that don't have MIME types. :(
++# Additional ones to be added to sndhdr? midi, mp3, realaudio, wma??
++def _what(data):
++ # Try to identify a sound file type.
++ #
++ # 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'
++ # command and use the standard 'magic' file, as shipped with a modern Unix.
++ for testfn in _rules:
++ if res := testfn(data):
++ return res
++ else:
++ return None
++
++
++def rule(rulefunc):
++ _rules.append(rulefunc)
++ return rulefunc
++
++
++@rule
++def _aiff(h):
++ if not h.startswith(b'FORM'):
++ return None
++ if h[8:12] in {b'AIFC', b'AIFF'}:
++ return 'x-aiff'
++ else:
++ return None
++
++
++@rule
++def _au(h):
++ if h.startswith(b'.snd'):
++ return 'basic'
++ else:
++ return None
++
++
++@rule
++def _wav(h):
++ # 'RIFF' <len> 'WAVE' 'fmt ' <len>
++ if not h.startswith(b'RIFF') or h[8:12] != b'WAVE' or h[12:16] != b'fmt ':
++ return None
++ else:
++ return "x-wav"