Revision: 7442
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7442&view=rev
Author:   efiring
Date:     2009-08-10 00:02:56 +0000 (Mon, 10 Aug 2009)

Log Message:
-----------
patch from sage project: make unicode_safe safer

Modified Paths:
--------------
    branches/v0_99_maint/lib/matplotlib/cbook.py

Modified: branches/v0_99_maint/lib/matplotlib/cbook.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/cbook.py        2009-08-09 20:58:24 UTC 
(rev 7441)
+++ branches/v0_99_maint/lib/matplotlib/cbook.py        2009-08-10 00:02:56 UTC 
(rev 7442)
@@ -13,13 +13,21 @@
 major, minor1, minor2, s, tmp = sys.version_info
 
 
-# on some systems, locale.getpreferredencoding returns None, which can break 
unicode
-preferredencoding = locale.getpreferredencoding()
+# 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.
 
+try:
+    preferredencoding = locale.getpreferredencoding()
+except ValueError:
+    preferredencoding = None
+
 def unicode_safe(s):
     if preferredencoding is None: return unicode(s)
     else: return unicode(s, preferredencoding)
 
+
 class converter:
     """
     Base class for handling string -> python type with support for


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to