From aaddc52da44822ba5d7ceb571c16f4b801612fd7 Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 19 Aug 2016 17:54:32 +0200 Subject: Set LC_NUMERIC to C to avoid segfaults on some platforms --- mpv.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'mpv.py') diff --git a/mpv.py b/mpv.py index 6448207..aae2717 100644 --- a/mpv.py +++ b/mpv.py @@ -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() -- cgit