[python] do not crash when reporting invalid locales

Summary:
When `LC_CTYPE` has an invalid value, `locale.getdefaultlocale()` raises
`ValueError` and infer crashes, which is embarrassing. Catch these errors and
report appropriately.

fixes #483

Reviewed By: akotulski

Differential Revision: D4182880

fbshipit-source-id: 31edcf7
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 2d846d89a6
commit ec9453d356

@ -157,8 +157,12 @@ def main():
touch_if_present=not args.continue_capture)
utils.configure_logging(args)
logging.info('output of locale.getdefaultlocale(): %s',
str(locale.getdefaultlocale()))
try:
logging.info('output of locale.getdefaultlocale(): %s',
str(locale.getdefaultlocale()))
except (locale.Error, ValueError) as e:
logging.info('locale.getdefaultlocale() failed with exception: %s',
str(e))
logging.info('encoding we chose in the end: %s',
config.CODESET)
logging.info('Running command %s',

Loading…
Cancel
Save