Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 47eb989

Browse filesBrowse files
authored
Merge pull request #8021 from tacaswell/fix_nonascii_afm
FIX: always decode bytes as utf-8 in AFM headers
2 parents 2b119b6 + b4a8191 commit 47eb989
Copy full SHA for 47eb989

File tree

Expand file treeCollapse file tree

3 files changed

+22
-5
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+22
-5
lines changed

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,7 @@ def tk_window_focus():
14721472

14731473
default_test_modules = [
14741474
'matplotlib.tests.test_agg',
1475+
'matplotlib.tests.test_afm',
14751476
'matplotlib.tests.test_animation',
14761477
'matplotlib.tests.test_arrow_patches',
14771478
'matplotlib.tests.test_artist',

‎lib/matplotlib/afm.py

Copy file name to clipboardExpand all lines: lib/matplotlib/afm.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
def _to_int(x):
5858
return int(float(x))
5959

60+
6061
_to_float = float
61-
if six.PY3:
62-
def _to_str(x):
63-
return x.decode('utf8')
64-
else:
65-
_to_str = str
62+
63+
64+
def _to_str(x):
65+
return x.decode('utf8')
6666

6767

6868
def _to_list_of_ints(s):

‎lib/matplotlib/tests/test_afm.py

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import (absolute_import, division, print_function,
4+
unicode_literals)
5+
6+
import matplotlib.afm as afm
7+
8+
9+
def test_nonascii_str():
10+
# This tests that we also decode bytes as utf-8 properly.
11+
# Else, font files with non ascii characters fail to load.
12+
inp_str = "привет"
13+
byte_str = inp_str.encode("utf8")
14+
15+
ret = afm._to_str(byte_str)
16+
assert ret == inp_str

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.