Package: blist
Followup-For: Bug #999365
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu jammy ubuntu-patch
Control: tags -1 patch

Sorry, there's a bit more required in order to make the package compatible
with python 3.10; even when the C extension builds successfully, the tests
will still fail because of python 3.10 language incompatibilities (which I
didn't notice before because they were masked by the gcc-11-induced
segfault).

Attached is a complete patch for python 3.10 compatibility.

Still working on the gcc-11 question; the package builds with noopt, and
without noopt the segfault isn't very debuggable...

-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                   https://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
diff -Nru blist-1.3.6/debian/patches/python-3.10.patch 
blist-1.3.6/debian/patches/python-3.10.patch
--- blist-1.3.6/debian/patches/python-3.10.patch        1969-12-31 
16:00:00.000000000 -0800
+++ blist-1.3.6/debian/patches/python-3.10.patch        2021-11-17 
15:45:43.000000000 -0800
@@ -0,0 +1,164 @@
+Description: Python 3.10 support
+ Py_REFCNT() is no longer an lvalue; use Py_SET_REFCNT() instead.
+ .
+ collections.MutableSet is obsolete, replaced by collections.abc.MutableSet.
+Author: Steve Langasek <steve.langa...@ubuntu.com>
+Last-Update: 2021-11-17
+Bug-Debian: https://bugs.debian.org/999365
+
+Index: blist-1.3.6/blist/_blist.c
+===================================================================
+--- blist-1.3.6.orig/blist/_blist.c
++++ blist-1.3.6/blist/_blist.c
+@@ -6595,7 +6595,7 @@
+         memcpy(&saved.BLIST_FIRST_FIELD, &self->BLIST_FIRST_FIELD,
+                sizeof(*self) - offsetof(PyBListRoot, BLIST_FIRST_FIELD));
+         Py_TYPE(&saved) = &PyRootBList_Type;
+-        Py_REFCNT(&saved) = 1;
++        Py_SET_REFCNT(&saved, 1);
+ 
+         if (extra_list != NULL) {
+                 self->children = extra_list;
+Index: blist-1.3.6/blist/__init__.py
+===================================================================
+--- blist-1.3.6.orig/blist/__init__.py
++++ blist-1.3.6/blist/__init__.py
+@@ -1,6 +1,6 @@
+ __version__ = '1.3.6'
+ from blist._blist import *
+-import collections
++import collections.abc as collections
+ if hasattr(collections, 'MutableSet'): # Only supported in Python 2.6+
+     from blist._sortedlist import sortedlist, sortedset, weaksortedlist, 
weaksortedset
+     from blist._sorteddict import sorteddict
+Index: blist-1.3.6/blist/_sortedlist.py
+===================================================================
+--- blist-1.3.6.orig/blist/_sortedlist.py
++++ blist-1.3.6/blist/_sortedlist.py
+@@ -25,7 +25,7 @@
+             del self.local.repr_count[self.ob_id]
+         return False
+ 
+-class _sortedbase(collections.Sequence):
++class _sortedbase(collections.abc.Sequence):
+     def __init__(self, iterable=(), key=None):
+         self._key = key
+         if key is not None and not hasattr(key, '__call__'):
+@@ -431,23 +431,23 @@
+ 
+ def safe_cmp(f):
+     def g(self, other):
+-        if not isinstance(other, collections.Set):
++        if not isinstance(other, collections.abc.Set):
+             raise TypeError("can only compare to a set")
+         return f(self, other)
+     return g
+ 
+-class _setmixin2(collections.MutableSet):
+-    "methods that override or supplement the collections.MutableSet methods"
++class _setmixin2(collections.abc.MutableSet):
++    "methods that override or supplement the collections.abc.MutableSet 
methods"
+ 
+-    __ror__ = collections.MutableSet.__or__
+-    __rand__ = collections.MutableSet.__and__
+-    __rxor__ = collections.MutableSet.__xor__
++    __ror__ = collections.abc.MutableSet.__or__
++    __rand__ = collections.abc.MutableSet.__and__
++    __rxor__ = collections.abc.MutableSet.__xor__
+ 
+     if sys.version_info[0] < 3: # pragma: no cover
+-        __lt__ = safe_cmp(collections.MutableSet.__lt__)
+-        __gt__ = safe_cmp(collections.MutableSet.__gt__)
+-        __le__ = safe_cmp(collections.MutableSet.__le__)
+-        __ge__ = safe_cmp(collections.MutableSet.__ge__)
++        __lt__ = safe_cmp(collections.abc.MutableSet.__lt__)
++        __gt__ = safe_cmp(collections.abc.MutableSet.__gt__)
++        __le__ = safe_cmp(collections.abc.MutableSet.__le__)
++        __ge__ = safe_cmp(collections.abc.MutableSet.__ge__)
+ 
+     def __ior__(self, it):
+         if self is it:
+@@ -479,7 +479,7 @@
+         return self._from_iterable(other) - self
+ 
+     def _make_set(self, iterable):
+-        if isinstance(iterable, collections.Set):
++        if isinstance(iterable, collections.abc.Set):
+             return iterable
+         return self._from_iterable(iterable)
+ 
+Index: blist-1.3.6/blist/_sorteddict.py
+===================================================================
+--- blist-1.3.6.orig/blist/_sorteddict.py
++++ blist-1.3.6/blist/_sorteddict.py
+@@ -6,7 +6,7 @@
+     def __missing__(self, key):
+         return self._missing(key)
+ 
+-class KeysView(collections.KeysView, collections.Sequence):
++class KeysView(collections.abc.KeysView, collections.abc.Sequence):
+     def __getitem__(self, index):
+         return self._mapping._sortedkeys[index]
+     def __reversed__(self):
+@@ -23,7 +23,7 @@
+         return self._mapping._sortedkeys.bisect_right(key)
+     bisect = bisect_right
+ 
+-class ItemsView(collections.ItemsView, collections.Sequence):
++class ItemsView(collections.abc.ItemsView, collections.abc.Sequence):
+     def __getitem__(self, index):
+         if isinstance(index, slice):
+             keys = self._mapping._sortedkeys[index]
+@@ -46,7 +46,7 @@
+       else:
+         return sortedset(it, key=lambda item: keyfunc(item[0]))
+ 
+-class ValuesView(collections.ValuesView, collections.Sequence):
++class ValuesView(collections.abc.ValuesView, collections.abc.Sequence):
+     def __getitem__(self, index):
+         if isinstance(index, slice):
+             keys = self._mapping._sortedkeys[index]
+@@ -54,7 +54,7 @@
+         key = self._mapping._sortedkeys[index]
+         return self._mapping[key]
+ 
+-class sorteddict(collections.MutableMapping):
++class sorteddict(collections.abc.MutableMapping):
+     def __init__(self, *args, **kw):
+         if hasattr(self, '__missing__'):
+             self._map = missingdict()
+Index: blist-1.3.6/blist/_btuple.py
+===================================================================
+--- blist-1.3.6.orig/blist/_btuple.py
++++ blist-1.3.6/blist/_btuple.py
+@@ -1,7 +1,7 @@
+ from blist._blist import blist
+ from ctypes import c_int
+ import collections
+-class btuple(collections.Sequence):
++class btuple(collections.abc.Sequence):
+     def __init__(self, seq=None):
+         if isinstance(seq, btuple):
+             self._blist = seq._blist
+Index: blist-1.3.6/blist/test/sortedlist_tests.py
+===================================================================
+--- blist-1.3.6.orig/blist/test/sortedlist_tests.py
++++ blist-1.3.6/blist/test/sortedlist_tests.py
+@@ -29,7 +29,7 @@
+                          repr(self.type2test()))
+ 
+     def validate_comparison(self, instance):
+-        if sys.version_info[0] < 3 and isinstance(instance, collections.Set):
++        if sys.version_info[0] < 3 and isinstance(instance, 
collections.abc.Set):
+             ops = ['ne', 'or', 'and', 'xor', 'sub']
+         else:
+             ops = ['lt', 'gt', 'le', 'ge', 'ne', 'or', 'and', 'xor', 'sub']
+@@ -185,7 +185,7 @@
+     def test_order(self):
+         stuff = [self.build_item(random.randrange(1000000))
+                  for i in range(1000)]
+-        if issubclass(self.type2test, collections.Set):
++        if issubclass(self.type2test, collections.abc.Set):
+             stuff = set(stuff)
+         sorted_stuff = list(sorted(stuff))
+         u = self.type2test
diff -Nru blist-1.3.6/debian/patches/series blist-1.3.6/debian/patches/series
--- blist-1.3.6/debian/patches/series   2020-10-15 10:05:56.000000000 -0700
+++ blist-1.3.6/debian/patches/series   2021-11-17 15:43:59.000000000 -0800
@@ -1,2 +1,3 @@
 0001-Catch-StopIteration-in-a-generator-and-return-instea.patch
 python3.9.patch
+python-3.10.patch

Reply via email to