commit:     1bfea2a1bcae233a9ff246dc4067524bdc013422
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 12:48:03 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Apr 21 15:43:43 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1bfea2a1

dev-python/fastbencode: Backport a patch for Cython-3.1 failures

Closes: https://bugs.gentoo.org/954095
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/fastbencode/fastbencode-0.3.1.ebuild    |  5 +++
 .../files/fastbencode-0.3.1-cython-3.1.patch       | 49 ++++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/dev-python/fastbencode/fastbencode-0.3.1.ebuild 
b/dev-python/fastbencode/fastbencode-0.3.1.ebuild
index 050e3c30fde5..a3f7ccbb53b9 100644
--- a/dev-python/fastbencode/fastbencode-0.3.1.ebuild
+++ b/dev-python/fastbencode/fastbencode-0.3.1.ebuild
@@ -24,3 +24,8 @@ BDEPEND="
 "
 
 distutils_enable_tests unittest
+
+PATCHES=(
+       # https://github.com/breezy-team/fastbencode/pull/97
+       "${FILESDIR}/${P}-cython-3.1.patch"
+)

diff --git a/dev-python/fastbencode/files/fastbencode-0.3.1-cython-3.1.patch 
b/dev-python/fastbencode/files/fastbencode-0.3.1-cython-3.1.patch
new file mode 100644
index 000000000000..7c65e47dfee8
--- /dev/null
+++ b/dev-python/fastbencode/files/fastbencode-0.3.1-cython-3.1.patch
@@ -0,0 +1,49 @@
+From 287a8ae762fd3e6d532cda7b899d08ec9859f84a Mon Sep 17 00:00:00 2001
+From: Jelmer Vernooij <jel...@jelmer.uk>
+Date: Mon, 21 Apr 2025 12:33:50 +0000
+Subject: [PATCH] Fix compatibility with Cython 3.1. Fixes #96
+
+---
+ fastbencode/_bencode_pyx.pyx | 9 +++------
+ 1 file changed, 3 insertions(+), 6 deletions(-)
+
+diff --git a/fastbencode/_bencode_pyx.pyx b/fastbencode/_bencode_pyx.pyx
+index 651f09f..c526b19 100644
+--- a/fastbencode/_bencode_pyx.pyx
++++ b/fastbencode/_bencode_pyx.pyx
+@@ -31,16 +31,13 @@ from cpython.bytes cimport (
+ from cpython.dict cimport (
+     PyDict_CheckExact,
+     )
+-from cpython.int cimport (
+-    PyInt_CheckExact,
+-    PyInt_FromString,
+-    )
+ from cpython.list cimport (
+     PyList_CheckExact,
+     PyList_Append,
+     )
+ from cpython.long cimport (
+     PyLong_CheckExact,
++    PyLong_FromString,
+     )
+ from cpython.mem cimport (
+     PyMem_Free,
+@@ -165,7 +162,7 @@ cdef class Decoder:
+         i = self._read_digits(c'e')
+         self.tail[i] = 0
+         try:
+-            ret = PyInt_FromString(self.tail, NULL, 10)
++            ret = PyLong_FromString(self.tail, NULL, 10)
+         finally:
+             self.tail[i] = c'e'
+         D_UPDATE_TAIL(self, i+1)
+@@ -414,7 +411,7 @@ cdef class Encoder:
+         try:
+             if PyBytes_CheckExact(x):
+                 self._encode_bytes(x)
+-            elif PyInt_CheckExact(x) and x.bit_length() < 32:
++            elif PyLong_CheckExact(x) and x.bit_length() < 32:
+                 self._encode_int(x)
+             elif PyLong_CheckExact(x):
+                 self._encode_long(x)

Reply via email to