From 49adf5933260836c17bc29b90a6ade50a803a83d Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 17 Aug 2016 03:36:01 -0700 Subject: [PATCH] do not crash when setting locale fails Summary: lolpython Reviewed By: akotulski Differential Revision: D3724416 fbshipit-source-id: f69d872 --- infer/lib/python/inferlib/config.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/infer/lib/python/inferlib/config.py b/infer/lib/python/inferlib/config.py index 69be17547..8d1402e5f 100644 --- a/infer/lib/python/inferlib/config.py +++ b/infer/lib/python/inferlib/config.py @@ -14,8 +14,11 @@ import locale import os -locale.setlocale(locale.LC_ALL, '') -CODESET = locale.getlocale(locale.LC_CTYPE)[1] +try: + locale.setlocale(locale.LC_ALL, '') + CODESET = locale.getlocale(locale.LC_CTYPE)[1] +except locale.Error: + CODESET = None if CODESET is None: CODESET = 'ascii'