-
-
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
Changes from all commits
ce92859
343f5fc
9278668
61758e3
7cdab88
1667a0c
b4a8191
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from __future__ import (absolute_import, division, print_function, | ||
unicode_literals) | ||
|
||
import matplotlib.afm as afm | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is missing our standard There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I've never seen a static checker complain about This is about consistent Python 2/3 behaviour, not some random import. |
||
|
||
|
||
def test_nonascii_str(): | ||
# This tests that we also decode bytes as utf-8 properly. | ||
# Else, font files with non ascii characters fail to load. | ||
inp_str = "привет" | ||
byte_str = inp_str.encode("utf8") | ||
|
||
ret = afm._to_str(byte_str) | ||
assert ret == inp_str |
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!