-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: always decode bytes as utf-8 in AFM headers #8021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is a 'can-not-import-bug', but has been here a long time, the critical flag is to make sure we talk about it. To test this I think we need to find a debian font which has a non-ascii font family name. |
I think just checking that afm._to_str works on non ascii path is enough. |
TST afm._to_str is now tested against utf8-encoded bytes
Can I still review this PR? (cause it looks very fine to me 👍 for merging!) |
@@ -0,0 +1,13 @@ | |||
import matplotlib.afm as afm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is missing our standard __future__
imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the future import is useless for this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, it might be harmful due to the 'unicode_literals'...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, if anyone adds new tests here, then they won't have to worry about adding in these imports if necessary. Easy consistency is important for tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the kind of practices that break static checkers such as pyflakes with very little benefit considering a forgotten import should break the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never seen a static checker complain about __future__
imports; how would they even know if you used, e.g., division
with types that were integers?
This is about consistent Python 2/3 behaviour, not some random import.
lib/matplotlib/tests/test_afm.py
Outdated
unicode_literals) | ||
|
||
import matplotlib.afm as afm | ||
import six |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that other changes mean this can be removed?
lib/matplotlib/tests/test_afm.py
Outdated
|
||
def test_nonascii_str(): | ||
# This tests that we also decode bytes as utf-8 properly. | ||
# Else, font files with non ascii caracters fail to load. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
caracters -> characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 since @NelleV made some changes I will leave this for @tacaswell to merge if he's happy with them
@@ -0,0 +1,14 @@ | |||
from __future__ import (absolute_import, division, print_function, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs an encoding comment; this fails on Python 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
closes #3517