Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_matching_blocks() fails on python3 #14

Closed
ojomio opened this issue Oct 23, 2014 · 4 comments
Closed

get_matching_blocks() fails on python3 #14

ojomio opened this issue Oct 23, 2014 · 4 comments

Comments

@ojomio
Copy link

ojomio commented Oct 23, 2014

Hello. I actually use a fuzzywuzzy package which relies on your repo, but suddenly I discovered that, when run on python3, tests for fuzzywuzzy produce output like that

ERROR: testWRatioUnicodeString (__main__.RatioTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_fuzzywuzzy.py", line 199, in testWRatioUnicodeString
    score = fuzz.WRatio(s1, s2, force_ascii=False)
  File "/home/crystal/github/fuzzywuzzy/fuzzywuzzy/fuzz.py", line 255, in WRatio
    partial = partial_ratio(p1, p2) * partial_scale
  File "/home/crystal/github/fuzzywuzzy/fuzzywuzzy/fuzz.py", line 77, in partial_ratio
    blocks = m.get_matching_blocks()
  File "/home/crystal/github/fuzzywuzzy/fuzzywuzzy/StringMatcher.py", line 57, in get_matching_blocks
    self._str1, self._str2)
TypeError: inverse expected a list of edit operations

StringMatcher.py is the same file as in your repo and it seems that there is some problem in get_matching_blocks() function, and only on python3. I haven't written extensions, so I tried to understand the root - but failed :(

Could you suggest the solutionfor this?

@ojomio ojomio changed the title get_matching_blocks() fails on python3 get_matching_blocks() fails on python3 Oct 23, 2014
ojomio added a commit to ojomio/python-Levenshtein that referenced this issue Oct 23, 2014
Now checks item not only for being an instance of bytes, but also checks to be an instance of str
@ztane
Copy link
Owner

ztane commented Oct 29, 2014

Thanks, will see this soon

@ztane
Copy link
Owner

ztane commented Dec 10, 2014

Hmm, indeed the patch given is not as right as it seems.

@ztane
Copy link
Owner

ztane commented Dec 10, 2014

I am inclined to decide that the right thing to do is always only support str(), that is the 8-bit bytestrings on python 2 and unicode strings on python 3, for editops.

@ztane
Copy link
Owner

ztane commented Dec 10, 2014

Fixed in the head and python-Levenshtein 0.12

@ztane ztane closed this as completed Dec 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants