Closed Zowie closed 9 years ago
fixed my problem
@Zowie I adopted your fix, but wrote it myself to encapsulate it into it's own function. See this commit: https://github.com/gregmuellegger/django-mobile/commit/a87c3599f250d34dab0c1b6114490c3e84ea85c1
Can you confirm that this fixes the issue you are having?
@gregmuellegger Jup, fixes it as well!
Released 0.5.1 which contains this fix. So installing should be easier now on Python 3. https://pypi.python.org/pypi/django-mobile/
I know this is a bit late, but io.open()
behaves consistently across both Python 2 and 3. It returns unicode strings when the mode set to 'rt' (the default), or byte strings when mode is 'rb'. Just use io.open('path/to/file', encoding='utf-8').read()
and you'll get Unicode strings with both Python 2 and 3.
@tysonclugg nevertheless its good input! Thanks, I will use io.open
in the future for these cases.
When installing with pip3, the following error is given:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 48: ordinal not in range(128)
It appears that if you don't explicitly set the encoding with locale.setlocale(locale.LC_ALL, 'en_US.utf-8') --- or whatever locale, just the encoding matters AFAIK --- python will try to decode files using ascii (the
locale.getpreferredencoding(False)
function thatopen()
actually depends on for the type of encoding it uses returns ANSI_X3.4-1968). This generates an issue where Python will say it cannot decode usingascii
and the installation will fail.I'm manually setting the encoding depending on the Python version now, i just copied line 48 (in old setup.py) to check the python version.