gcapizzi/freitag — pull request #1 by berdario (2013-06-27 12:11:06+00:00)
Title: fixed encoding problem

I checked out the differences between our setup.py files:

- Pip compatibility: apparently, pip deals just fine with distutils projects even when uninstalling (it has problems with distutils2, but that one is dead in the water)
- Entry points: You had to create the `bin/freitag` script (setuptools can create it automatically, if you supply it the entry point )
- Test commands: when running `./setup.py test` setuptools downloads the test dependencies for you... distutils lacks it

They are minor annoyances, and I chose to merge your `setup.py` to stay close to upstream

That said, the fix could be a simple `unicode(value, 'UTF-8')` but that wouldn't deal with systems that aren't using an UTF-8 locale

Unfortunately Python2 requires you to do `locale.setlocale(locale.LC_ALL, '')` to access the user defaults

OTOH, in Python3 you don't even need to `import locale`, since the problem originates with the filename received from `argparse`: in Python3 `argparse` is locale-aware and will automatically return you a unicode string

I usually do `value.decode(ENCODING)`: this works on both Py2 and 3, but I left `unicode()` in... it's marginally faster and that code can be just stripped off altogether in the Python3 branch