commit:     2ba096c8e518d9e764f1890dc2bf9782bfc00c55
Author:     Petr Vaněk <arkamar <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 15 10:12:38 2024 +0000
Commit:     Petr Vaněk <arkamar <AT> gentoo <DOT> org>
CommitDate: Sat Jun 15 10:19:25 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2ba096c8

dev-python/python-mimeparse: enable py3.13

It was necessary to backport the patch [1].

[1] https://github.com/falconry/python-mimeparse/pull/46

Signed-off-by: Petr Vaněk <arkamar <AT> gentoo.org>

 .../files/python-mimeparse-1.6.0-py3.13.patch      | 79 ++++++++++++++++++++++
 .../python-mimeparse-1.6.0-r5.ebuild               | 28 ++++++++
 2 files changed, 107 insertions(+)

diff --git 
a/dev-python/python-mimeparse/files/python-mimeparse-1.6.0-py3.13.patch 
b/dev-python/python-mimeparse/files/python-mimeparse-1.6.0-py3.13.patch
new file mode 100644
index 000000000000..90b4c4fc7d8a
--- /dev/null
+++ b/dev-python/python-mimeparse/files/python-mimeparse-1.6.0-py3.13.patch
@@ -0,0 +1,79 @@
+From 5427072b12119fe28fd66f19f74beb7da0c1de8b Mon Sep 17 00:00:00 2001
+From: Stanis Trendelenburg <stanis.trendelenb...@gmail.com>
+Date: Mon, 1 Jan 2024 12:48:19 +0100
+Subject: [PATCH] chore(cgi): include `parse_header()` from the deprecated cgi
+ module (#46)
+
+* Include functions from the deprecated cgi module
+
+* Document source of vendored functions from cgi.py
+
+* Fix linter error
+---
+
+Upstream-PR: https://github.com/falconry/python-mimeparse/pull/46
+
+diff --git a/mimeparse.py b/mimeparse.py
+index 0de6d57..506e138 100644
+--- a/mimeparse.py
++++ b/mimeparse.py
+@@ -1,5 +1,3 @@
+-import cgi
+-
+ __version__ = '1.6.0'
+ __author__ = 'Joe Gregorio'
+ __email__ = 'j...@bitworking.org'
+@@ -11,6 +9,44 @@ class MimeTypeParseException(ValueError):
+     pass
+ 
+ 
++# Vendored version of cgi._parseparam from Python 3.11 (deprecated and slated
++# for removal in 3.13)
++def _parseparam(s):
++    while s[:1] == ';':
++        s = s[1:]
++        end = s.find(';')
++        while end > 0 and (s.count('"', 0, end) - s.count('\\"', 0, end)) % 2:
++            end = s.find(';', end + 1)
++        if end < 0:
++            end = len(s)
++        f = s[:end]
++        yield f.strip()
++        s = s[end:]
++
++
++# Vendored version of cgi.parse_header from Python 3.11 (deprecated and slated
++# for removal in 3.13)
++def _parse_header(line):
++    """Parse a Content-type like header.
++
++    Return the main content-type and a dictionary of options.
++
++    """
++    parts = _parseparam(';' + line)
++    key = parts.__next__()
++    pdict = {}
++    for p in parts:
++        i = p.find('=')
++        if i >= 0:
++            name = p[:i].strip().lower()
++            value = p[i + 1:].strip()
++            if len(value) >= 2 and value[0] == value[-1] == '"':
++                value = value[1:-1]
++                value = value.replace('\\\\', '\\').replace('\\"', '"')
++            pdict[name] = value
++    return key, pdict
++
++
+ def parse_mime_type(mime_type):
+     """Parses a mime-type into its component parts.
+ 
+@@ -23,7 +59,7 @@ def parse_mime_type(mime_type):
+ 
+     :rtype: (str,str,dict)
+     """
+-    full_type, params = cgi.parse_header(mime_type)
++    full_type, params = _parse_header(mime_type)
+     # Java URLConnection class sends an Accept header that includes a
+     # single '*'. Turn it into a legal wildcard.
+     if full_type == '*':

diff --git a/dev-python/python-mimeparse/python-mimeparse-1.6.0-r5.ebuild 
b/dev-python/python-mimeparse/python-mimeparse-1.6.0-r5.ebuild
new file mode 100644
index 000000000000..e0164a2e170c
--- /dev/null
+++ b/dev-python/python-mimeparse/python-mimeparse-1.6.0-r5.ebuild
@@ -0,0 +1,28 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYPI_NO_NORMALIZE=1
+PYTHON_COMPAT=( python3_{10..13} pypy3 )
+
+inherit distutils-r1 pypi
+
+DESCRIPTION="Basic functions for handling mime-types in python"
+HOMEPAGE="
+       https://github.com/falconry/python-mimeparse/
+       https://pypi.org/project/python-mimeparse/
+"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 
~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos"
+
+PATCHES=(
+       "${FILESDIR}/${P}-py3.13.patch"
+)
+
+python_test() {
+       "${EPYTHON}" mimeparse_test.py -v || die "Tests fail with ${EPYTHON}"
+}

Reply via email to