diff --git a/examples/pylab_examples/font_table_ttf.py b/examples/pylab_examples/font_table_ttf.py old mode 100644 new mode 100755 index 6400efb0bb3d..0a80c535dce4 --- a/examples/pylab_examples/font_table_ttf.py +++ b/examples/pylab_examples/font_table_ttf.py @@ -32,7 +32,7 @@ for ccode, glyphind in codes: if ccode>=256: continue r,c = divmod(ccode,16) - s = chr(ccode) + s = unichr(ccode) chars[r][c] = s diff --git a/lib/matplotlib/cbook.py b/lib/matplotlib/cbook.py index c3d8ff596394..cd1dc68e197e 100644 --- a/lib/matplotlib/cbook.py +++ b/lib/matplotlib/cbook.py @@ -1820,7 +1820,11 @@ def __call__(self, key): def is_math_text(s): # Did we find an even number of non-escaped dollar signs? # If so, treat is as math text. - s = unicode(s) + try: + s = unicode(s) + except UnicodeDecodeError: + raise ValueError( + "matplotlib display text must have all code points < 128 or use Unicode strings") dollar_count = s.count(r'$') - s.count(r'\$') even_dollars = (dollar_count > 0 and dollar_count % 2 == 0)