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

wikiteam/dumpgenerator.py:2260: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal #435

Open
cooperdk opened this issue Jun 13, 2022 · 0 comments

Comments

@cooperdk
Copy link

cooperdk commented Jun 13, 2022

The current error appears if you resume a crawl and there are images not downloaded.
This error must have been present for years, or it may be due to modules that were updated thus not supporting this code.

(dumpgenerator.py)

The error is in line 2260, which is:

if filename2 not in listdir:

The error occurs because the code is trying to compare unicode with non-unicode. This happens in Python 2.7 when not carefully saving files in a format supported by the OS (I am running this from a Synology NAS currently, which means a current Linux).

It is fixed by modifying the listdir code (line 2245-2246) thus:

CHG            listdir = os.listdir('%s/images' % (config['path']))
ADD            listdir2 = [x.encode('utf-8') for x in listdir]
ADD            listdir = listdir2

(in essence, converting the list to a UTF-8 encoded similar list

And in what is now line 2262 (former 2260 but now two lines further down due to the two new lines):

CHG            if filename2.encode('utf-8') not in listdir:

This now ensures the script matches a UTF-8 encoded string with a UTF-8 encoded string and not a UTF-string with bytes or anything else.

It is still advised to spend energy on the WikiTeam3 project as it makes no sense to keep this code alive anymore.

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

1 participant