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

Closes: https://bugs.gentoo.org/954095
Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2025-04-21 14:48:03 +02:00
parent e26d930e00
commit 1bfea2a1bc
2 changed files with 54 additions and 0 deletions

View File

@@ -24,3 +24,8 @@ BDEPEND="
"
distutils_enable_tests unittest
PATCHES=(
# https://github.com/breezy-team/fastbencode/pull/97
"${FILESDIR}/${P}-cython-3.1.patch"
)

View File

@@ -0,0 +1,49 @@
From 287a8ae762fd3e6d532cda7b899d08ec9859f84a Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij <jelmer@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)