Set LC_NUMERIC to C to avoid segfaults on some platforms

This commit is contained in:
jaseg 2016-08-19 17:54:32 +02:00
parent ab8b8b5477
commit aaddc52da4
1 changed files with 6 additions and 0 deletions

6
mpv.py
View File

@ -14,6 +14,12 @@ if os.name == 'nt':
backend = CDLL(ctypes.util.find_library('mpv-1.dll'))
fs_enc = 'utf-8'
else:
import locale
lc, enc = locale.getlocale(locale.LC_NUMERIC)
# libmpv requires LC_NUMERIC to be set to "C". Since messing with global variables everyone else relies upon is
# still better than segfaulting, we are setting LC_NUMERIC to "C".
locale.setlocale(locale.LC_NUMERIC, 'C')
backend = CDLL(ctypes.util.find_library('mpv'))
fs_enc = sys.getfilesystemencoding()