Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df428f0

Browse files
committed
Display a more helpful error message when an 8-bit non-ascii string is passed to matplotlib.
1 parent 519322f commit df428f0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/cbook.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,11 @@ def __call__(self, key):
18201820
def is_math_text(s):
18211821
# Did we find an even number of non-escaped dollar signs?
18221822
# If so, treat is as math text.
1823-
s = unicode(s)
1823+
try:
1824+
s = unicode(s)
1825+
except UnicodeDecodeError:
1826+
raise ValueError(
1827+
"matplotlib display text must have all code points < 128 or use Unicode strings")
18241828

18251829
dollar_count = s.count(r'$') - s.count(r'\$')
18261830
even_dollars = (dollar_count > 0 and dollar_count % 2 == 0)

0 commit comments

Comments
 (0)