trezor / trezor-common

:lock: Don't post issues/PRs to here, use the new monorepo:
https://github.com/trezor/trezor-firmware
GNU Lesser General Public License v3.0
91 stars 232 forks source link

Fix build with python 3.6 #247

Closed ehaupt closed 5 years ago

ehaupt commented 5 years ago

Fix build with python 3.6

prusnak commented 5 years ago

What does import locale ; locale.getpreferredencoding() return? What OS are you on?

ehaupt commented 5 years ago
# python3.6
Python 3.6.7 (default, Dec  4 2018, 01:10:52) 
[GCC 4.2.1 Compatible FreeBSD Clang 6.0.0 (tags/RELEASE_600/final 326565)] on freebsd11
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getpreferredencoding()
'UTF-8'

This is due to my custom locale:

$ locale
LANG=C
LC_CTYPE=de_CH.UTF-8
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY=de_CH.UTF-8
LC_MESSAGES="C"
LC_ALL=

On a vanilla FreeBSD installation you'd get:

$ locale
LANG=C
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=C
# python3.6
Python 3.6.7 (default, Dec  4 2018, 01:10:52) 
[GCC 4.2.1 Compatible FreeBSD Clang 6.0.0 (tags/RELEASE_600/final 326565)] on freebsd11
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale ; locale.getpreferredencoding()
'US-ASCII'
matejcik commented 5 years ago

I'm inclined to say that non-UTF locales are unsupported.

I mean, we could explicitly specify encoding everywhere and it's a technically correct solution. OTOH, all our tooling is based on Click, which very explicitly does not support ASCII locales, so it's somewhat pointless. So explicit encoding would only support other non-UTF locales (iso8859-*? shift-jis?) which are rather rare these days and personally I'm okay with declaring them unsupported.

What do you think @prusnak?

prusnak commented 5 years ago

I am fine with declaring non-UTF-8 locales as unsupported.

matejcik commented 5 years ago

alright, closing