commit:     dd8f1804d5781a492398d1cfa8a6f901a09c54cf
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 26 21:18:48 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Sep 26 21:19:29 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dd8f1804

dev-python/patiencediff: backport clang 15 patch

Closes: https://bugs.gentoo.org/869995
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/patiencediff-0.2.3-wint-conversion.patch | 84 ++++++++++++++++++++++
 .../patiencediff/patiencediff-0.2.3-r1.ebuild      | 31 ++++++++
 2 files changed, 115 insertions(+)

diff --git 
a/dev-python/patiencediff/files/patiencediff-0.2.3-wint-conversion.patch 
b/dev-python/patiencediff/files/patiencediff-0.2.3-wint-conversion.patch
new file mode 100644
index 000000000000..3a8fd9fc1293
--- /dev/null
+++ b/dev-python/patiencediff/files/patiencediff-0.2.3-wint-conversion.patch
@@ -0,0 +1,84 @@
+https://github.com/breezy-team/patiencediff/commit/24e26cd2929e01dc8ef47fb71b3b87536ad43947
+
+From 24e26cd2929e01dc8ef47fb71b3b87536ad43947 Mon Sep 17 00:00:00 2001
+From: Sam James <[email protected]>
+Date: Mon, 26 Sep 2022 21:49:47 +0100
+Subject: [PATCH] Use designated initialiser syntax for PyTypeObject
+
+Fixes build with Clang. Switch to the more readable designated
+initialiser syntax to avoid having to lookup member order.
+
+Before, Clang would complain:
+```
+clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe 
-fdiagnostics-color=always -frecord-gcc-switches -fPIC 
-I/usr/include/python3.10 -c patiencediff/_patiencediff_c.c -o 
build/temp.linux-x86_64-cpython-310/patiencediff/_patiencediff_c.o
+patiencediff/_patiencediff_c.c:1175:5: error: incompatible pointer to integer 
conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 
'void *' [-Wint-conversion]
+    NULL, /* tp_print */
+    ^~~~
+/usr/include/wchar.h:46:14: note: expanded from macro 'NULL'
+             ^~~~~~~~~~
+```
+
+This is because some of PyTypeObject's members are actually
+Py_ssize_t so chucking a NULL in looks like a codesmell to Clang.
+
+See https://docs.python.org/3/c-api/typeobj.html#quick-reference
+and https://docs.python.org/3/c-api/typeobj.html#examples.
+
+Bug: https://bugs.gentoo.org/869995
+Closes: https://github.com/breezy-team/patiencediff/issues/12
+Signed-off-by: Sam James <[email protected]>
+--- a/patiencediff/_patiencediff_c.c
++++ b/patiencediff/_patiencediff_c.c
+@@ -1168,44 +1168,13 @@ static char PatienceSequenceMatcher_doc[] =
+ 
+ static PyTypeObject PatienceSequenceMatcherType = {
+     PyVarObject_HEAD_INIT(NULL, 0)
+-    "PatienceSequenceMatcher",  /* tp_name */
+-    sizeof(PatienceSequenceMatcher), /* tp_basicsize */
+-    0, /* tp_itemsize */
+-    (destructor)PatienceSequenceMatcher_dealloc, /* tp_dealloc */
+-    NULL, /* tp_print */
+-    NULL, /* tp_getattr */
+-    NULL, /* tp_setattr */
+-    NULL, /* tp_compare */
+-    NULL, /* tp_repr */
+-    NULL, /* tp_as_number */
+-    NULL, /* tp_as_sequence */
+-    NULL, /* tp_as_mapping */
+-    NULL, /* tp_hash */
+-    NULL, /* tp_call */
+-    NULL, /* tp_str */
+-    NULL, /* tp_getattro */
+-    NULL, /* tp_setattro */
+-    NULL, /* tp_as_buffer */
+-    Py_TPFLAGS_DEFAULT, /* tp_flags */
+-    PatienceSequenceMatcher_doc, /* tp_doc */
+-    NULL, /* tp_traverse */
+-    NULL, /* tp_clear */
+-    NULL, /* tp_richcompare */
+-    0, /* tp_weaklistoffset */
+-    NULL, /* tp_iter */
+-    NULL, /* tp_iternext */
+-    PatienceSequenceMatcher_methods, /* tp_methods */
+-    NULL, /* tp_members */
+-    NULL, /* tp_getset */
+-    NULL, /* tp_base */
+-    NULL, /* tp_dict */
+-    NULL, /* tp_descr_get */
+-    NULL, /* tp_descr_set */
+-    0, /* tp_dictoffset */
+-    NULL, /* tp_init */
+-    NULL, /* tp_alloc */
+-    PatienceSequenceMatcher_new, /* NULL */
+-    NULL, /* tp_free */
++    .tp_name = "PatienceSequenceMatcher",
++    .tp_basicsize = sizeof(PatienceSequenceMatcher),
++    .tp_dealloc = (destructor)PatienceSequenceMatcher_dealloc,
++    .tp_flags = Py_TPFLAGS_DEFAULT,
++    .tp_doc = PatienceSequenceMatcher_doc,
++    .tp_methods = PatienceSequenceMatcher_methods,
++    .tp_new = PatienceSequenceMatcher_new,
+ };
+ 
+ 
+

diff --git a/dev-python/patiencediff/patiencediff-0.2.3-r1.ebuild 
b/dev-python/patiencediff/patiencediff-0.2.3-r1.ebuild
new file mode 100644
index 000000000000..71db75366bb9
--- /dev/null
+++ b/dev-python/patiencediff/patiencediff-0.2.3-r1.ebuild
@@ -0,0 +1,31 @@
+# Copyright 2021-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{8..11} pypy3 )
+
+inherit distutils-r1
+
+DESCRIPTION="Python implementation of the patiencediff algorithm"
+HOMEPAGE="
+       https://github.com/breezy-team/patiencediff/
+       https://pypi.org/project/patiencediff/
+"
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-wint-conversion.patch
+)
+
+distutils_enable_tests unittest
+
+python_test() {
+       cd "${BUILD_DIR}/install$(python_get_sitedir)" || die
+       eunittest
+}

Reply via email to