diff piecrust/main.py @ 167:0a1736ef740d

chef: Work around a bug in MacOSX where the default locale doesn't work.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 02 Jan 2015 19:47:41 -0800
parents 028df35a690e
children 869a206facd5
line wrap: on
line diff
--- a/piecrust/main.py	Thu Jan 01 23:13:38 2015 -0800
+++ b/piecrust/main.py	Fri Jan 02 19:47:41 2015 -0800
@@ -52,6 +52,16 @@
 
 
 def main():
+    if sys.platform == 'darwin':
+        # There's a bug on MacOSX that can cause Python to be confused
+        # about the locale. Let's try to fix that.
+        # See: http://bugs.python.org/issue18378
+        import locale
+        try:
+            locale.getdefaultlocale()
+        except ValueError:
+            locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
+
     argv = sys.argv
     pre_args = _pre_parse_chef_args(argv)
     try: