|
From: <ef...@us...> - 2010-06-14 02:54:05
|
Revision: 8433
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8433&view=rev
Author: efiring
Date: 2010-06-14 02:53:59 +0000 (Mon, 14 Jun 2010)
Log Message:
-----------
cbook: handle empty string returned by locale.getpreferredencoding
Reported by Huziy Oleksandr.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/cbook.py
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py 2010-06-14 02:33:37 UTC (rev 8432)
+++ trunk/matplotlib/lib/matplotlib/cbook.py 2010-06-14 02:53:59 UTC (rev 8433)
@@ -23,11 +23,14 @@
# On some systems, locale.getpreferredencoding returns None,
# which can break unicode; and the sage project reports that
# some systems have incorrect locale specifications, e.g.,
-# an encoding instead of a valid locale name.
+# an encoding instead of a valid locale name. Another
+# pathological case that has been reported is an empty string.
try:
- preferredencoding = locale.getpreferredencoding()
-except (ValueError, ImportError):
+ preferredencoding = locale.getpreferredencoding().strip()
+ if not preferredencoding:
+ preferredencoding = None
+except (ValueError, ImportError, AttributeError):
preferredencoding = None
def unicode_safe(s):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|