bskinn / sphobjinv

Toolkit for manipulation and inspection of Sphinx objects.inv files
https://sphobjinv.readthedocs.io
MIT License
78 stars 9 forks source link

UnicodeDecodeError #225

Closed oscargus closed 2 years ago

oscargus commented 2 years ago

Brief description

Not clear if this is a bug/limitation in sphobjinv or if the objects.inv in question is messed up, but I get a UnicodeDecodeError for

sphobjinv suggest -u https://fonttools.readthedocs.io/en/latest/objects.inv TTFont

(and related versions of the call)

Expected behavior

A suggestion.

Actual behavior

No inventory at provided URL.
Attempting "https://fonttools.readthedocs.io/en/latest/objects.inv" ...
Remote inventory found.

Traceback (most recent call last):
  File "/local/data1/miniconda3/bin/sphobjinv", line 8, in <module>
    sys.exit(main())
  File "/local/data1/miniconda3/lib/python3.8/site-packages/sphobjinv/cli/core.py", line 214, in main
    do_suggest(inv, params)
  File "/local/data1/miniconda3/lib/python3.8/site-packages/sphobjinv/cli/core.py", line 109, in do_suggest
    results = inv.suggest(
  File "/local/data1/miniconda3/lib/python3.8/site-packages/sphobjinv/inventory.py", line 530, in suggest
    for match, score in fwp.extract(name, srch_list, limit=None)
  File "/local/data1/miniconda3/lib/python3.8/site-packages/sphobjinv/_vendored/fuzzywuzzy/process.py", line 60, in extract
    processed = processor(choice)
  File "/local/data1/miniconda3/lib/python3.8/site-packages/sphobjinv/_vendored/fuzzywuzzy/process.py", line 51, in <lambda>
    processor = lambda x: utils.asciidammit(x)
  File "/local/data1/miniconda3/lib/python3.8/site-packages/sphobjinv/_vendored/fuzzywuzzy/utils.py", line 17, in asciidammit
    return asciionly(s)
  File "/local/data1/miniconda3/lib/python3.8/site-packages/sphobjinv/_vendored/fuzzywuzzy/utils.py", line 12, in asciionly
    return s.encode().translate(None, bad_chars).decode()  # B Skinn 2021-12-11
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 21: invalid continuation byte

To reproduce

sphobjinv suggest -u https://fonttools.readthedocs.io/en/latest/objects.inv TTFont

Attachments

System information

Python environment

Python

Python 3.8.12 | packaged by conda-forge | (default, Jan 30 2022, 23:42:07) [GCC 9.4.0]

Libraries

Skipping this, let me know if required. **Additional information**
bskinn commented 2 years ago

Thanks for the report!

This objects.inv works fine with sphobjinv v2.1, so likely this problem stems from my having to vendor in an old version of fuzzywuzzy (#211). This will take some mucking around with the innards of fuzzywuzzy to fix.

I'll be happy to get this figured out and fixed; but, it'll probably take at least a couple of weeks to get to the point of a v2.2.2 with the fix. If you're interested in working on it, I'd also be quite happy to accept a PR for it.

oscargus commented 2 years ago

I (surprisingly) found an easy workaround and submitted a PR. Feel free to reject it as it is sort of "quick and dirty", but it seems to at least avoid the problem (and I can perform the request).

bskinn commented 2 years ago

v2.2.2 is up on PyPI, ready to use!