rapidfuzz/RapidFuzz

'OverflowError' object is not subscriptable

Closed this issue · 3 comments

Hi,

i'm trying to update the package python3-rapidfuzz for Void Linux.

I get 'OverflowError' object is not subscriptable when testing the package after cross-compiling for i686 architecture
Packages for other architectures pass the tests successfully.

There were no errors when i packaged version 3.5.2

See the full log here - https://github.com/void-linux/void-packages/actions/runs/7333701739/job/19969496724?pr=47916#step:7:714

Here is the partial log:

============================= test session starts ==============================
platform linux -- Python 3.12.1, pytest-7.4.3, pluggy-1.2.0
rootdir: /builddir/python3-rapidfuzz-3.6.0
configfile: pyproject.toml
testpaths: tests
plugins: hypothesis-6.92.0
collected 377 items

tests/test_fuzz.py ..................................................... [ 14%]
........................................................................ [ 33%]
..............................                                           [ 41%]
tests/test_hypothesis.py ............FFF..............                   [ 48%]
tests/test_process.py ...............F.................                  [ 57%]
tests/test_utils.py .                                                    [ 57%]
tests/distance/test_DamerauLevenshtein.py FFFFFFFFFFFFFFFFF              [ 62%]
tests/distance/test_Hamming.py FFF.F                                     [ 63%]
tests/distance/test_Indel.py FF.F                                        [ 64%]
tests/distance/test_Jaro.py ...                                          [ 65%]
tests/distance/test_JaroWinkler.py ...                                   [ 66%]
tests/distance/test_LCSseq.py F.F                                        [ 67%]
tests/distance/test_Levenshtein.py FFFF..FF                              [ 69%]
tests/distance/test_OSA.py FFFFFF                                        [ 70%]
tests/distance/test_Postfix.py FFF                                       [ 71%]
tests/distance/test_Prefix.py FFF                                        [ 72%]
tests/distance/test_distance.py ....................FFF..FFFFFFFF..FFFFF [ 83%]
FFF..FFFFFFFF..FFFFFFFF..FFFFFFFF..FFFFF                                 [ 93%]
tests/distance/test_init.py ........................                     [100%]

=================================== FAILURES ===================================
____________________________ test_levenshtein_word _____________________________

    @given(s1=st.text(max_size=64), s2=st.text(max_size=64))
>   @settings(max_examples=50, deadline=None)

f          = <function given.<locals>.run_test_as_given.<locals>.wrapped_test at 0xed2ab7f8>

tests/test_hypothesis.py:329: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_hypothesis.py:337: in test_levenshtein_word
    assert Levenshtein.distance(s1, s2) == reference_dist
        reference_dist = 0
        s1         = ''
        s2         = ''
tests/common.py:311: in distance
    dist, _, _, _ = self._validate(s1, s2, **kwargs)
        kwargs     = {}
        s1         = ''
        s2         = ''
        self       = <tests.common.GenericScorer object at 0xed16fd20>
tests/common.py:289: in _validate
    dist = call_and_maybe_catch(self._distance, s1, s2, **kwargs)
        kwargs     = {}
        maximum    = 0
        s1         = ''
        s2         = ''
        self       = <tests.common.GenericScorer object at 0xed16fd20>
tests/common.py:42: in call_and_maybe_catch
    raise e
        args       = ('', '')
        call       = <bound method GenericScorer._distance of <tests.common.GenericScorer object at 0xed16fd20>>
        kwargs     = {}
tests/common.py:40: in call_and_maybe_catch
    return call(*args, **kwargs)
        args       = ('', '')
        call       = <bound method GenericScorer._distance of <tests.common.GenericScorer object at 0xed16fd20>>
        kwargs     = {}
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.common.GenericScorer object at 0xed16fd20>, s1 = '', s2 = ''
kwargs = {}, symmetric = True
tester = <function symmetric_scorer_tester at 0xed6cfac8>
scores = [0, TypeError("'OverflowError' object is not subscriptable"), TypeError("'OverflowError' object is not subscriptable")]
score = TypeError("'OverflowError' object is not subscriptable")

    def _distance(self, s1, s2, **kwargs):
        symmetric = self.get_scorer_flags(s1, s2, **kwargs)["symmetric"]
        tester = symmetric_scorer_tester if symmetric else scorer_tester
    
        scores = [call_and_maybe_catch(tester, scorer.distance, s1, s2, **kwargs) for scorer in self.scorers]
    
        if any(isinstance(score, Exception) for score in scores):
            for score in scores:
>               assert compare_exceptions(score, scores[0])
E               AssertionError
E               Falsifying example: test_levenshtein_word(
E                   # The test always failed when commented parts were varied together.
E                   s1='',  # or any other generated value
E                   s2='',  # or any other generated value
E               )

kwargs     = {}
s1         = ''
s2         = ''
score      = TypeError("'OverflowError' object is not subscriptable")
scores     = [0, TypeError("'OverflowError' object is not subscriptable"), TypeError("'OverflowError' object is not subscriptable")]
self       = <tests.common.GenericScorer object at 0xed16fd20>
symmetric  = True
tester     = <function symmetric_scorer_tester at 0xed6cfac8>

tests/common.py:228: AssertionError

Not really sure what the issue here is. I will improve the tests later today so it prints the stacktrace for these exceptions. Are you able to patch the tests for this target to rerun the tests with these changes?

I was able to reproduce the issue in my own CI. Looking into it.

Fixed in a0e6bdd. I will upload a new patch release with the fix later today.

Thanks for reporting.