Package: python3-xapian-haystack
Version: 2.1.1-1
Severity: grave
Tags: upstream patch
Justification: renders package unusable

Dear Maintainer,

I installed python3-xapian-haystack in order to employ Xapian as a
Haystack backend in mailman3-web on stable (bookworm).

However, upon actually trying to use it, I got the following traceback:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/django/core/handlers/exception.py", line 
47, in inner
    response = get_response(request)
  File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 181, 
in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3/dist-packages/hyperkitty/views/search.py", line 54, in 
search
    results = EmptySearchQuerySet()
  File "/usr/lib/python3/dist-packages/haystack/query.py", line 25, in __init__
    self._determine_backend()
  File "/usr/lib/python3/dist-packages/haystack/query.py", line 58, in 
_determine_backend
    self.query = connections[backend_alias].get_query()
  File "/usr/lib/python3/dist-packages/haystack/utils/loading.py", line 114, in 
__getitem__
    self.thread_local.connections[key] = load_backend(
  File "/usr/lib/python3/dist-packages/haystack/utils/loading.py", line 60, in 
load_backend
    return import_class(full_backend_path)
  File "/usr/lib/python3/dist-packages/haystack/utils/loading.py", line 22, in 
import_class
    module_itself = importlib.import_module(module_path)
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
    <source code not available>
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
    <source code not available>
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
    <source code not available>
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
    <source code not available>
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
    <source code not available>
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
    <source code not available>
  File "/usr/lib/python3/dist-packages/xapian_backend.py", line 10, in <module>
    from django.utils import six

Exception Type: ImportError at /hyperkitty/search
Exception Value: cannot import name 'six' from 'django.utils' 
(/usr/lib/python3/dist-packages/django/utils/__init__.py)

django.utils.six was removed in Django 3.0; the version of Django in
stable is 3.2. Hence python3-xapian-haystack is currently unusable in
stable, as it simply throws an ImportError upon loading.

Upstream fixed this issue when they dropped Python 2 support in [0].
However, I have a simpler patch that just removes the six import and
changes all occurences of `six.moves.range()` to the built-in `range()`,
which I've applied locally (hence the debsums complaint) and seems to do
the trick.

I would very much like a stable-update for this given that the package
simply does not work without the patch.

Many thanks,
Ole

[0]: 
https://github.com/notanumber/xapian-haystack/commit/0f9d94fb23ebf8cf194a3a88948a86f6dc69e786#diff-b4466d919fc4105c6306804abd396d6e0ba5e4630346928df34a5308c4700d97

-- System Information:
Debian Release: 12.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 
'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.7.8 (SMP w/16 CPU threads; PREEMPT)
Locale: LANG=en_DK.UTF-8, LC_CTYPE=en_DK.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_NO:en_DK:en_US:en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages python3-xapian-haystack depends on:
ii  python3                  3.11.2-1+b1
ii  python3-django-haystack  3.2.1-1
ii  python3-xapian           1.4.22-1

python3-xapian-haystack recommends no packages.

python3-xapian-haystack suggests no packages.

-- no debconf information

-- debsums errors found:
debsums: changed file /usr/lib/python3/dist-packages/xapian_backend.py (from 
python3-xapian-haystack package)
--- xapian_backend.py   2017-05-18 08:50:23.000000000 +0200
+++ /usr/lib/python3/dist-packages/xapian_backend.py    2024-03-12 
01:06:33.011301452 +0100
@@ -7,7 +7,6 @@
 import shutil
 import sys
 
-from django.utils import six
 from django.conf import settings
 from django.core.exceptions import ImproperlyConfigured
 from django.utils.encoding import force_text
@@ -346,7 +345,7 @@
             def _get_ngram_lengths(value):
                 values = value.split()
                 for item in values:
-                    for ngram_length in six.moves.range(NGRAM_MIN_LENGTH, 
NGRAM_MAX_LENGTH + 1):
+                    for ngram_length in range(NGRAM_MIN_LENGTH, 
NGRAM_MAX_LENGTH + 1):
                         yield item, ngram_length
 
             for obj in iterable:
@@ -356,8 +355,8 @@
                 def ngram_terms(value):
                     for item, length in _get_ngram_lengths(value):
                         item_length = len(item)
-                        for start in six.moves.range(0, item_length - length + 
1):
-                            for size in six.moves.range(length, length + 1):
+                        for start in range(0, item_length - length + 1):
+                            for size in range(length, length + 1):
                                 end = start + size
                                 if end > item_length:
                                     continue

Reply via email to