LibraryOfCongress / bagit-python

Work with BagIt packages from Python.
http://libraryofcongress.github.io/bagit-python
218 stars 85 forks source link

UnicodeWarning when using en dash in command line metadata argument #127

Closed t4k closed 5 years ago

t4k commented 5 years ago

I'm using a command like bagit.py --external-description 'A folder, 1902–1904, from a Series' /path/to/folder and I am getting the warning bagit.py:1554: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal if "--version" in sys.argv:

I have deduced that it is because of the en dash in the date range. What can be done?

t4k commented 5 years ago

…and the trick was to install bagit-python with pip3 install bagit and use python3 -m bagit as the command.

kba commented 5 years ago

I have deduced that it is because of the en dash in the date range. What can be done?

It's just a warning. Since string literals (like "--version" but it has nothing to do with the dashes) are unicode (because from __future__ import unicode_literals) but sys.argv is a list of str and str != unicode in python2, you get this warning.

But using python3 is the sensible thing to do anyway.