django-extensions/django-extensions — pull request #404 by SeiryuZ (2013-11-07 08:55:33+00:00)
Title: Fixed wrong usage of six.u on widont

This Pull Request is to fix error ``Exception Value: decoding Unicode is not supported`` from wrong usage of ``six.u`` introduced on this commit https://github.com/django-extensions/django-extensions/commit/eeb5441ce062eed77fa82372704efb0108ffb1ae

For python2.7, the line ``' %s' % matchobj.group(1)`` is evaluated as unicode string. ``six.u`` will throw an error on providing unicode string as an argument.

```python
def replace(matchobj):
return six.u(' %s' % matchobj.group(1))
for i in range(count):
value = re_widont.sub(replace, force_unicode(value))
```

I remedied this issue by using django's own ``force_unicode`` method that handle converting string to unicode for python2.

Also added are tests that catch this issues.

Feel free to comment or change the code.