A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-checkins/2009-September/085890.html below:

[Python-checkins] r74687 - python/branches/py3k/Lib/locale.py

[Python-checkins] r74687 - python/branches/py3k/Lib/locale.py [Python-checkins] r74687 - python/branches/py3k/Lib/locale.pyronald.oussoren python-checkins at python.org
Sun Sep 6 15:59:02 CEST 2009
Author: ronald.oussoren
Date: Sun Sep  6 15:59:02 2009
New Revision: 74687

Log:
Fix for issue 6393: Python crashes on OSX when $LANG is set to some (but
not all) invalid values due to an invalid result from nl_langinfo


Modified:
   python/branches/py3k/Lib/locale.py

Modified: python/branches/py3k/Lib/locale.py
==============================================================================
--- python/branches/py3k/Lib/locale.py	(original)
+++ python/branches/py3k/Lib/locale.py	Sun Sep  6 15:59:02 2009
@@ -570,10 +570,22 @@
                 except Error:
                     pass
                 result = nl_langinfo(CODESET)
+                if not result and sys.platform == 'darwin':
+                    # nl_langinfo can return an empty string
+                    # when the setting has an invalid value.
+                    # Default to UTF-8 in that case because
+                    # UTF-8 is the default charset on OSX and
+                    # returning nothing will crash the
+                    # interpreter.
+                    result = 'UTF-8'
+
                 setlocale(LC_CTYPE, oldloc)
                 return result
             else:
-                return nl_langinfo(CODESET)
+                result = nl_langinfo(CODESET)
+                if not result and sys.platform == 'darwin':
+                    # See above for explanation
+                    result = 'UTF-8'
 
 
 ### Database
More information about the Python-checkins mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4