Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-BTrees for openSUSE:Factory checked in at 2026-11-16 15:14:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-BTrees (Old) and /work/SRC/openSUSE:Factory/.python-BTrees.new.1251 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-BTrees" Mon Nov 16 15:14:42 2026 rev:26 rq:1397874 version:6.5 Changes: -------- --- /work/SRC/openSUSE:Factory/python-BTrees/python-BTrees.changes 2026-05-04 12:58:04.364729334 +0200 +++ /work/SRC/openSUSE:Factory/.python-BTrees.new.1251/python-BTrees.changes 2026-11-16 15:14:50.381284253 +0100 @@ -1,0 +2,10 @@ +Fri Nov 6 10:54:43 UTC 2026 - Danilo Spinella <[email protected]> + +- Update to 6.5 + * Add support for Python 3.15. + * Remove the long deprecated byValue() method from all Bucket and + * Fix the pure-Python byValue() so it matches the C + implementation: it now +- Fix malformed nested python_expand in the install section + +------------------------------------------------------------------- Old: ---- btrees-6.4.tar.gz New: ---- btrees-6.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-BTrees.spec ++++++ --- /var/tmp/diff_new_pack.TuTVN4/_old 2026-11-16 15:14:51.437328787 +0100 +++ /var/tmp/diff_new_pack.TuTVN4/_new 2026-11-16 15:14:51.439328871 +0100 @@ -19,7 +19,7 @@ %{?sle15_python_module_pythons} Name: python-BTrees -Version: 6.4 +Version: 6.5 Release: 0 Summary: Persistent B-tree object containers for Python License: ZPL-2.1 @@ -67,9 +67,8 @@ %install %pyproject_install -%{python_expand rm %{buildroot}%{$python_sitearch}/BTrees/*.c - %fdupes %{buildroot}%{$python_sitearch} -} +%python_expand rm %{buildroot}%{$python_sitearch}/BTrees/*.c +%python_expand %fdupes %{buildroot}%{$python_sitearch} %check # the failing tests would require this step which setup.py test did: ++++++ btrees-6.4.tar.gz -> btrees-6.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/CHANGES.rst new/btrees-6.5/CHANGES.rst --- old/btrees-6.4/CHANGES.rst 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/CHANGES.rst 2026-08-20 13:30:54.000000000 +0200 @@ -1,6 +1,29 @@ Change log ========== +6.5 (2026-08-20) +---------------- + +- Add support for Python 3.15. + +- Remove the long deprecated ``byValue()`` method from all ``Bucket`` and + ``BTree`` classes except those of the ``II`` and ``LL`` families, which are + the modules reachable as ``BTrees.family32.II`` and ``BTrees.family64.II``. + + For families with object values ``byValue()`` could crash the interpreter: + a value whose comparison method mutated the bucket freed the array the C + code was iterating over. Removing the method resolves that, see `issue 226 + <https://github.com/zopefoundation/BTrees/issues/226>`_. + + The declaration moved from ``BTrees.Interfaces.IDictionaryIsh`` to the new + ``BTrees.Interfaces.IByValue``, which only the remaining implementations + provide. + +- Fix the pure-Python ``byValue()`` so it matches the C implementation: it now + normalizes the values by dividing them by ``min`` (when ``min`` is positive) + before sorting, and returns a list. + + 6.4 (2026-04-29) ---------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/PKG-INFO new/btrees-6.5/PKG-INFO --- old/btrees-6.4/PKG-INFO 2026-04-29 08:46:20.130122700 +0200 +++ new/btrees-6.5/PKG-INFO 2026-08-20 13:31:39.787928300 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: BTrees -Version: 6.4 +Version: 6.5 Summary: Scalable persistent object containers Author-email: Zope Foundation and contributors <[email protected]> Maintainer-email: Plone Foundation and contributors <[email protected]> @@ -21,6 +21,7 @@ Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: 3.14 +Classifier: Programming Language :: Python :: 3.15 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Database @@ -76,6 +77,29 @@ Change log ========== +6.5 (2026-08-20) +---------------- + +- Add support for Python 3.15. + +- Remove the long deprecated ``byValue()`` method from all ``Bucket`` and + ``BTree`` classes except those of the ``II`` and ``LL`` families, which are + the modules reachable as ``BTrees.family32.II`` and ``BTrees.family64.II``. + + For families with object values ``byValue()`` could crash the interpreter: + a value whose comparison method mutated the bucket freed the array the C + code was iterating over. Removing the method resolves that, see `issue 226 + <https://github.com/zopefoundation/BTrees/issues/226>`_. + + The declaration moved from ``BTrees.Interfaces.IDictionaryIsh`` to the new + ``BTrees.Interfaces.IByValue``, which only the remaining implementations + provide. + +- Fix the pure-Python ``byValue()`` so it matches the C implementation: it now + normalizes the values by dividing them by ``min`` (when ``min`` is positive) + before sorting, and returns a list. + + 6.4 (2026-04-29) ---------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/docs/api.rst new/btrees-6.5/docs/api.rst --- old/btrees-6.4/docs/api.rst 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/docs/api.rst 2026-08-20 13:30:54.000000000 +0200 @@ -37,6 +37,7 @@ .. autointerface:: IKeySequence .. autointerface:: IMinimalDictionary .. autointerface:: IDictionaryIsh +.. autointerface:: IByValue .. autointerface:: IMerge .. autointerface:: IIMerge .. autointerface:: IMergeIntegerKey diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/docs/overview.rst new/btrees-6.5/docs/overview.rst --- old/btrees-6.4/docs/overview.rst 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/docs/overview.rst 2026-08-20 13:30:54.000000000 +0200 @@ -122,13 +122,18 @@ a few extensions that exploit the fact that the keys are sorted. The example below demonstrates how some of the methods work. The extra methods are :func:`minKey` and :func:`maxKey`, which find the minimum and maximum -key value subject to an optional bound argument, and :func:`byValue`, which -should probably be ignored (it's hard to explain exactly what it does, and -as a result it's almost never used -- best to consider it deprecated). The -various methods for enumerating keys, values and items also accept minimum -and maximum key arguments ("range search"), and (new in ZODB 3.3) optional -Boolean arguments to control whether a range search is inclusive or -exclusive of the range's endpoints. +key value subject to an optional bound argument. The various methods for +enumerating keys, values and items also accept minimum and maximum key +arguments ("range search"), and (new in ZODB 3.3) optional Boolean +arguments to control whether a range search is inclusive or exclusive of +the range's endpoints. + +There is also :func:`byValue`, which should be considered deprecated: it is +hard to explain exactly what it does, and as a result it is almost never +used. Since version 6.5 it only exists on the ``Bucket`` and ``BTree`` +classes of the ``II`` and ``LL`` families -- that is, on +``BTrees.family32.II`` and ``BTrees.family64.II``. See +:class:`BTrees.Interfaces.IByValue`. .. doctest:: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/pyproject.toml new/btrees-6.5/pyproject.toml --- old/btrees-6.4/pyproject.toml 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/pyproject.toml 2026-08-20 13:30:54.000000000 +0200 @@ -10,7 +10,7 @@ [project] name = "BTrees" -version = "6.4" +version = "6.5" description = "Scalable persistent object containers" dynamic = ["readme"] requires-python = ">=3.10" @@ -34,6 +34,7 @@ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Database", @@ -96,3 +97,8 @@ [tool.setuptools.dynamic] readme = {file = ["README.rst", "CHANGES.rst"]} + +[tool.zest-releaser] +create-wheel = false +extra-message = "" +upload-pypi = false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/setup.cfg new/btrees-6.5/setup.cfg --- old/btrees-6.4/setup.cfg 2026-04-29 08:46:20.131641100 +0200 +++ new/btrees-6.5/setup.cfg 2026-08-20 13:31:39.788605700 +0200 @@ -1,6 +1,3 @@ -[zest.releaser] -create-wheel = no - [flake8] doctests = 1 per-file-ignores = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/BTreeModuleTemplate.c new/btrees-6.5/src/BTrees/BTreeModuleTemplate.c --- old/btrees-6.4/src/BTrees/BTreeModuleTemplate.c 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/BTreeModuleTemplate.c 2026-08-20 13:30:54.000000000 +0200 @@ -51,7 +51,10 @@ */ #define MODULE_NAME "BTrees." MOD_NAME_PREFIX "BTree." -static PyObject *sort_str, *reverse_str, *__setstate___str; +#ifdef SUPPORT_BY_VALUE +static PyObject *sort_str, *reverse_str; +#endif +static PyObject *__setstate___str; static PyObject *_bucket_type_str, *max_internal_size_str, *max_leaf_size_str; static PyObject *__slotnames__str; static PyObject *ConflictError = NULL; @@ -631,12 +634,14 @@ return NULL; #endif +#ifdef SUPPORT_BY_VALUE sort_str = PyUnicode_InternFromString("sort"); if (!sort_str) return NULL; reverse_str = PyUnicode_InternFromString("reverse"); if (!reverse_str) return NULL; +#endif __setstate___str = PyUnicode_InternFromString("__setstate__"); if (!__setstate___str) return NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/BTreeTemplate.c new/btrees-6.5/src/BTrees/BTreeTemplate.c --- old/btrees-6.4/src/BTrees/BTreeTemplate.c 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/BTreeTemplate.c 2026-08-20 13:30:54.000000000 +0200 @@ -1885,6 +1885,7 @@ return BTree_rangeSearch(self, args, kw, 'i'); } +#ifdef SUPPORT_BY_VALUE static PyObject * BTree_byValue(BTree *self, PyObject *omin) { @@ -1965,6 +1966,7 @@ Py_XDECREF(item); return NULL; } +#endif /* SUPPORT_BY_VALUE */ /* ** BTree_getm @@ -2251,11 +2253,13 @@ "Returns the items of the BTree. If min and max are supplied, only\n" "items with keys greater than min and less than max are returned."}, +#ifdef SUPPORT_BY_VALUE {"byValue", (PyCFunction) BTree_byValue, METH_O, "byValue(min) -> list of value, key pairs\n\n" "Returns list of value, key pairs where the value is >= min. The\n" "list is sorted by value. Note that items() returns keys in the\n" "opposite order."}, +#endif {"get", (PyCFunction) BTree_getm, METH_VARARGS, "get(key[, default=None]) -> Value for key or default\n\n" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/BucketTemplate.c new/btrees-6.5/src/BTrees/BucketTemplate.c --- old/btrees-6.4/src/BTrees/BucketTemplate.c 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/BucketTemplate.c 2026-08-20 13:30:54.000000000 +0200 @@ -1013,6 +1013,7 @@ return NULL; } +#ifdef SUPPORT_BY_VALUE static PyObject * bucket_byValue(Bucket *self, PyObject *omin) { @@ -1085,6 +1086,7 @@ Py_XDECREF(item); return NULL; } +#endif /* SUPPORT_BY_VALUE */ static int _bucket_clear(Bucket *self) @@ -1734,9 +1736,11 @@ {"items", (PyCFunction) bucket_items, METH_VARARGS | METH_KEYWORDS, "items([min, max])) -- Return the items"}, +#ifdef SUPPORT_BY_VALUE {"byValue", (PyCFunction) bucket_byValue, METH_O, "byValue(min) -- " "Return value-keys with values >= min and reverse sorted by values"}, +#endif {"get", (PyCFunction) bucket_getm, METH_VARARGS, "get(key[,default]) -- Look up a value\n\n" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/Interfaces.py new/btrees-6.5/src/BTrees/Interfaces.py --- old/btrees-6.4/src/BTrees/Interfaces.py 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/Interfaces.py 2026-08-20 13:30:54.000000000 +0200 @@ -308,14 +308,6 @@ (key, value) pairs. """ - def byValue(minValue): - """Return a sequence of (value, key) pairs, sorted by value. - - Values < minValue are omitted and other values are "normalized" by - the minimum value. This normalization may be a noop, but, for - integer values, the normalization is division. - """ - def setdefault(key, d): """D.setdefault(k, d) -> D.get(k, d), also set D[k]=d if k not in D. @@ -346,6 +338,30 @@ """ +class IByValue(Interface): + """Support for the deprecated ``byValue`` method. + + Only the ``Bucket`` and ``BTree`` classes of the ``II`` and ``LL`` + families provide this, that is the modules reachable as + ``BTrees.family32.II`` and ``BTrees.family64.II``. + + .. versionchanged:: 6.5 + Previously ``byValue`` was declared on + :class:`~BTrees.Interfaces.IDictionaryIsh` and implemented by every + family. It could crash the interpreter for families with object + values, so it was removed everywhere except where it is actually + used. See `issue 226 + <https://github.com/zopefoundation/BTrees/issues/226>`_. + """ + + def byValue(minValue): + """Return a sequence of (value, key) pairs, sorted by value. + + Values < minValue are omitted and other values are "normalized" by + the minimum value, which for these integer values means division. + """ + + class IBTree(IDictionaryIsh): def insert(key, value): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/_IIBTree.c new/btrees-6.5/src/BTrees/_IIBTree.c --- old/btrees-6.4/src/BTrees/_IIBTree.c 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/_IIBTree.c 2026-08-20 13:30:54.000000000 +0200 @@ -26,8 +26,11 @@ #define MOD_NAME_PREFIX "II" - - +/* ``byValue`` only exists for the ``II`` and ``LL`` families, the two + modules reachable as ``family32.II`` and ``family64.II``. See + https://github.com/zopefoundation/BTrees/issues/226 +*/ +#define SUPPORT_BY_VALUE #include "Python.h" #include "intkeymacros.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/_LLBTree.c new/btrees-6.5/src/BTrees/_LLBTree.c --- old/btrees-6.4/src/BTrees/_LLBTree.c 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/_LLBTree.c 2026-08-20 13:30:54.000000000 +0200 @@ -26,8 +26,11 @@ #define MOD_NAME_PREFIX "LL" - - +/* ``byValue`` only exists for the ``II`` and ``LL`` families, the two + modules reachable as ``family32.II`` and ``family64.II``. See + https://github.com/zopefoundation/BTrees/issues/226 +*/ +#define SUPPORT_BY_VALUE #define ZODB_64BIT_INTS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/_base.py new/btrees-6.5/src/BTrees/_base.py --- old/btrees-6.4/src/BTrees/_base.py 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/_base.py 2026-08-20 13:30:54.000000000 +0200 @@ -1413,10 +1413,6 @@ excludemin=False, excludemax=False): return iter(self.items(min, max, excludemin, excludemax)) - def byValue(self, min): - return reversed( - sorted((v, k) for (k, v) in self.iteritems() if v >= min)) - def insert(self, key, value): return bool(self._set(key, value, True)[0]) @@ -1441,6 +1437,24 @@ _p_resolveConflict = _Tree._p_resolveConflict +def byValue(self, min): + """Implementation of ``BTrees.Interfaces.IByValue.byValue``. + + Only attached to the ``Bucket`` and ``BTree`` classes of the ``II`` and + ``LL`` families; see ``_module_builder._create_classes``. + + Mirrors the C ``NORMALIZE_VALUE`` semantics: values are divided by *min* + when *min* is positive, and the division happens *before* sorting, since + it can make distinct values compare equal. + """ + items = [(v, k) for (k, v) in self.iteritems() if v >= min] + if min > 0: + items = [(v // min, k) for (v, k) in items] + items.sort() + items.reverse() + return items + + class set_operation: __slots__ = ( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/_fsBTree.c new/btrees-6.5/src/BTrees/_fsBTree.c --- old/btrees-6.4/src/BTrees/_fsBTree.c 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/_fsBTree.c 2026-08-20 13:30:54.000000000 +0200 @@ -67,8 +67,6 @@ PyErr_SetString(PyExc_TypeError, "expected six-character string key"); \ (STATUS)=0; } -#define NORMALIZE_VALUE(V, MIN) - #include "Python.h" static PyObject *bucket_toBytes(PyObject *self); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/_module_builder.py new/btrees-6.5/src/BTrees/_module_builder.py --- old/btrees-6.4/src/BTrees/_module_builder.py 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/_module_builder.py 2026-08-20 13:30:54.000000000 +0200 @@ -21,6 +21,16 @@ from zope.interface import directlyProvides +#: The families that still provide the deprecated ``byValue``: the modules +#: reachable as ``family32.II`` and ``family64.II``. It was removed +#: everywhere else, see +#: https://github.com/zopefoundation/BTrees/issues/226 +_BY_VALUE_PREFIXES = frozenset({'II', 'LL'}) + +#: The classes within those families that provide ``byValue``. +_BY_VALUE_CLASSES = frozenset({'Bucket', 'BTree'}) + + def _create_classes( module_name, key_datatype, value_datatype, ): @@ -31,6 +41,7 @@ from ._base import TreeSet from ._base import _TreeItems as TreeItems from ._base import _TreeIterator + from ._base import byValue classes = {} @@ -65,6 +76,8 @@ )) cls.__module__ = module_name key_datatype.add_extra_methods(base_name, cls) + if prefix in _BY_VALUE_PREFIXES and base_name in _BY_VALUE_CLASSES: + cls.byValue = byValue classes[cls.__name__] = cls # Importing the C extension does this for the non-py @@ -182,6 +195,11 @@ classImplements(mod_globals[cls_name], iface) classImplements(mod_globals[cls_name + 'Py'], iface) + if prefix in _BY_VALUE_PREFIXES: + for cls_name in _BY_VALUE_CLASSES: + classImplements(mod_globals[cls_name], interfaces.IByValue) + classImplements(mod_globals[cls_name + 'Py'], interfaces.IByValue) + for cls_name, abc in { 'BTree': collections.abc.MutableMapping, 'Bucket': collections.abc.MutableMapping, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/floatvaluemacros.h new/btrees-6.5/src/BTrees/floatvaluemacros.h --- old/btrees-6.4/src/BTrees/floatvaluemacros.h 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/floatvaluemacros.h 2026-08-20 13:30:54.000000000 +0200 @@ -19,8 +19,6 @@ PyErr_SetString(PyExc_TypeError, "expected float or int value"); \ (STATUS)=0; (TARGET)=0; } -#define NORMALIZE_VALUE(V, MIN) ((MIN) > 0) ? ((V)/=(MIN)) : 0 - #define MERGE_DEFAULT 1.0f #define MERGE(O1, w1, O2, w2) ((O1)*(w1)+(O2)*(w2)) #define MERGE_WEIGHT(O, w) ((O)*(w)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/objectvaluemacros.h new/btrees-6.5/src/BTrees/objectvaluemacros.h --- old/btrees-6.4/src/BTrees/objectvaluemacros.h 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/objectvaluemacros.h 2026-08-20 13:30:54.000000000 +0200 @@ -19,4 +19,3 @@ #define COPY_VALUE(k,e) k=(e) #define COPY_VALUE_TO_OBJECT(O, K) O=(K); Py_INCREF(O) #define COPY_VALUE_FROM_ARG(TARGET, ARG, S) TARGET=(ARG) -#define NORMALIZE_VALUE(V, MIN) Py_INCREF(V) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/tests/testBTrees.py new/btrees-6.5/src/BTrees/tests/testBTrees.py --- old/btrees-6.4/src/BTrees/tests/testBTrees.py 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/tests/testBTrees.py 2026-08-20 13:30:54.000000000 +0200 @@ -11,6 +11,7 @@ # FOR A PARTICULAR PURPOSE # ############################################################################## +import importlib import unittest from BTrees.tests.common import permutations @@ -547,3 +548,116 @@ f2, = u.load() self.assertIs(f1, family) self.assertIs(f2, family) + + +class TestByValue(unittest.TestCase): + # ``byValue`` used to exist for every family, where it could crash the + # interpreter for object values. It now only exists for the ``II`` and + # ``LL`` families, the modules reachable as ``BTrees.family32.II`` and + # ``BTrees.family64.II``. + # https://github.com/zopefoundation/BTrees/issues/226 + + # The classes that have ``byValue`` in those two families. ``Set`` and + # ``TreeSet`` never had it. + CLASS_NAMES = ('Bucket', 'BTree', 'BucketPy', 'BTreePy') + + WITH_BY_VALUE = ('IIBTree', 'LLBTree') + WITHOUT_BY_VALUE = ( + 'OOBTree', 'IOBTree', 'IFBTree', 'IUBTree', + 'OIBTree', 'UUBTree', 'QQBTree', 'fsBTree', + ) + + def _classes(self, module_names, class_names=CLASS_NAMES): + for module_name in module_names: + module = importlib.import_module('BTrees.' + module_name) + for class_name in class_names: + yield module_name, class_name, getattr(module, class_name) + + def test_present_for_II_and_LL(self): + for mod, name, cls in self._classes(self.WITH_BY_VALUE): + with self.subTest(module=mod, cls=name): + self.assertTrue(hasattr(cls, 'byValue')) + + def test_absent_everywhere_else(self): + for mod, name, cls in self._classes(self.WITHOUT_BY_VALUE): + with self.subTest(module=mod, cls=name): + self.assertFalse(hasattr(cls, 'byValue')) + + def test_absent_from_sets(self): + for mod, name, cls in self._classes( + self.WITH_BY_VALUE + self.WITHOUT_BY_VALUE, + ('Set', 'TreeSet', 'SetPy', 'TreeSetPy')): + with self.subTest(module=mod, cls=name): + self.assertFalse(hasattr(cls, 'byValue')) + + def test_values_are_normalized_by_min(self): + # Values are divided by ``min`` when ``min`` is positive, and the + # result is sorted descending. The division makes 30 // 20 and + # 20 // 20 tie at 1, so the key breaks the tie. + for mod, name, cls in self._classes(self.WITH_BY_VALUE): + with self.subTest(module=mod, cls=name): + mapping = cls({1: 10, 2: 20, 3: 30, 4: 40, 5: 50}) + self.assertEqual( + list(mapping.byValue(20)), + [(2, 5), (2, 4), (1, 3), (1, 2)]) + + def test_values_are_not_normalized_by_a_non_positive_min(self): + for mod, name, cls in self._classes(self.WITH_BY_VALUE): + with self.subTest(module=mod, cls=name): + mapping = cls({1: -10, 2: 0, 3: 10}) + self.assertEqual( + list(mapping.byValue(0)), [(10, 3), (0, 2)]) + self.assertEqual( + list(mapping.byValue(-10)), [(10, 3), (0, 2), (-10, 1)]) + + def test_C_and_Python_implementations_agree(self): + items = {1: 10, 2: 20, 3: 30, 4: 40, 5: 50} + for module_name in self.WITH_BY_VALUE: + module = importlib.import_module('BTrees.' + module_name) + for class_name in ('Bucket', 'BTree'): + c_class = getattr(module, class_name) + py_class = getattr(module, class_name + 'Py') + for min_value in (-1, 0, 1, 20, 100): + with self.subTest(module=module_name, cls=class_name, + min=min_value): + self.assertEqual( + list(c_class(items).byValue(min_value)), + list(py_class(items).byValue(min_value))) + + def test_IByValue_is_provided_only_where_byValue_exists(self): + from zope.interface.verify import verifyObject + + from BTrees.Interfaces import IByValue + + for mod, name, cls in self._classes(self.WITH_BY_VALUE): + with self.subTest(module=mod, cls=name): + self.assertTrue(verifyObject(IByValue, cls())) + for mod, name, cls in self._classes(self.WITHOUT_BY_VALUE): + with self.subTest(module=mod, cls=name): + self.assertFalse(IByValue.providedBy(cls())) + + def test_IDictionaryIsh_no_longer_declares_byValue(self): + from BTrees.Interfaces import IDictionaryIsh + + self.assertNotIn('byValue', IDictionaryIsh) + + def test_issue_226_reproducer_no_longer_reaches_C_code(self): + # The reproducer from the issue used to segfault the interpreter. + # ``OOBucket`` no longer has ``byValue`` at all. + from BTrees.OOBTree import OOBucket + + bucket = OOBucket() + + class Mutating: + def __lt__(self, other): + bucket.clear() + return False + + def __eq__(self, other): + return False + + __hash__ = object.__hash__ + + bucket[1] = Mutating() + with self.assertRaises(AttributeError): + bucket.byValue(object()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/tests/test_OOBTree.py new/btrees-6.5/src/BTrees/tests/test_OOBTree.py --- old/btrees-6.4/src/BTrees/tests/test_OOBTree.py 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/tests/test_OOBTree.py 2026-08-20 13:30:54.000000000 +0200 @@ -19,12 +19,6 @@ class OOBTreeTest(BTreeTests): - def test_byValue(self): - ITEMS = [(y, x) for x, y in enumerate('abcdefghijklmnopqrstuvwxyz')] - tree = self._makeOne(ITEMS) - self.assertEqual(list(tree.byValue(22)), - [(y, x) for x, y in reversed(ITEMS[22:])]) - def testRejectDefaultComparisonOnSet(self): # Check that passing in keys w default comparison fails. Only # applies to new-style class instances if we're using the C diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees/tests/test__base.py new/btrees-6.5/src/BTrees/tests/test__base.py --- old/btrees-6.4/src/BTrees/tests/test__base.py 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/src/BTrees/tests/test__base.py 2026-08-20 13:30:54.000000000 +0200 @@ -2469,12 +2469,6 @@ max='f', excludemax=True)), ITEMS[2:5]) - def test_byValue(self): - ITEMS = [(y, x) for x, y in enumerate('abcdefghijklmnopqrstuvwxyz')] - tree = self._makeOne(ITEMS) - self.assertEqual(list(tree.byValue(min=22)), - [(y, x) for x, y in reversed(ITEMS[22:])]) - def test_insert_new_key(self): tree = self._makeOne() self.assertTrue(tree.insert('a', 0)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/src/BTrees.egg-info/PKG-INFO new/btrees-6.5/src/BTrees.egg-info/PKG-INFO --- old/btrees-6.4/src/BTrees.egg-info/PKG-INFO 2026-04-29 08:46:20.000000000 +0200 +++ new/btrees-6.5/src/BTrees.egg-info/PKG-INFO 2026-08-20 13:31:39.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: BTrees -Version: 6.4 +Version: 6.5 Summary: Scalable persistent object containers Author-email: Zope Foundation and contributors <[email protected]> Maintainer-email: Plone Foundation and contributors <[email protected]> @@ -21,6 +21,7 @@ Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: 3.14 +Classifier: Programming Language :: Python :: 3.15 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Database @@ -76,6 +77,29 @@ Change log ========== +6.5 (2026-08-20) +---------------- + +- Add support for Python 3.15. + +- Remove the long deprecated ``byValue()`` method from all ``Bucket`` and + ``BTree`` classes except those of the ``II`` and ``LL`` families, which are + the modules reachable as ``BTrees.family32.II`` and ``BTrees.family64.II``. + + For families with object values ``byValue()`` could crash the interpreter: + a value whose comparison method mutated the bucket freed the array the C + code was iterating over. Removing the method resolves that, see `issue 226 + <https://github.com/zopefoundation/BTrees/issues/226>`_. + + The declaration moved from ``BTrees.Interfaces.IDictionaryIsh`` to the new + ``BTrees.Interfaces.IByValue``, which only the remaining implementations + provide. + +- Fix the pure-Python ``byValue()`` so it matches the C implementation: it now + normalizes the values by dividing them by ``min`` (when ``min`` is positive) + before sorting, and returns a list. + + 6.4 (2026-04-29) ---------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrees-6.4/tox.ini new/btrees-6.5/tox.ini --- old/btrees-6.4/tox.ini 2026-04-29 08:45:31.000000000 +0200 +++ new/btrees-6.5/tox.ini 2026-08-20 13:30:54.000000000 +0200 @@ -21,7 +21,6 @@ pip_pre = py315: true deps = setuptools >= 78.1.1,< 82 - Sphinx setenv = pure: PURE_PYTHON=1 !pure-!pypy3: PURE_PYTHON=0
