mirror of
https://github.com/powerline/powerline.git
synced 2025-07-27 07:44:36 +02:00
Fix LC_MESSAGES AttributeError
Adds code to check if locale has the 'LC_MESSAGES' attribute before executing the following line of code: locale.getlocale(locale.LC_MESSAGES)[1] Fixes #1555
This commit is contained in:
parent
d7e913280c
commit
2f1893a968
@ -43,9 +43,15 @@ def get_preferred_output_encoding():
|
|||||||
Falls back to ASCII, so that output is most likely to be displayed
|
Falls back to ASCII, so that output is most likely to be displayed
|
||||||
correctly.
|
correctly.
|
||||||
'''
|
'''
|
||||||
|
if hasattr(locale, 'LC_MESSAGES'):
|
||||||
|
return (
|
||||||
|
locale.getlocale(locale.LC_MESSAGES)[1]
|
||||||
|
or locale.getdefaultlocale()[1]
|
||||||
|
or 'ascii'
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
locale.getlocale(locale.LC_MESSAGES)[1]
|
locale.getdefaultlocale()[1]
|
||||||
or locale.getdefaultlocale()[1]
|
|
||||||
or 'ascii'
|
or 'ascii'
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -57,9 +63,15 @@ def get_preferred_input_encoding():
|
|||||||
Falls back to latin1 so that function is less likely to throw as decoded
|
Falls back to latin1 so that function is less likely to throw as decoded
|
||||||
output is primary searched for ASCII values.
|
output is primary searched for ASCII values.
|
||||||
'''
|
'''
|
||||||
|
if hasattr(locale, 'LC_MESSAGES'):
|
||||||
|
return (
|
||||||
|
locale.getlocale(locale.LC_MESSAGES)[1]
|
||||||
|
or locale.getdefaultlocale()[1]
|
||||||
|
or 'latin1'
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
locale.getlocale(locale.LC_MESSAGES)[1]
|
locale.getdefaultlocale()[1]
|
||||||
or locale.getdefaultlocale()[1]
|
|
||||||
or 'latin1'
|
or 'latin1'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user