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

Skip to content

Commit d93b525

Browse files
committed
Deprecate passing bytes to FT2Font.set_text.
The bytes object was previously implicitly interpreted as a latin-1 str, but we're not on Py2 anymore :-)
1 parent faffaa1 commit d93b525

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
Deprecations
22
------------
3+
4+
Passing `bytes` to ``FT2Font.set_text``
5+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
... is deprecated, pass `str` instead.

src/ft2font_wrapper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,13 @@ static PyObject *PyFT2Font_set_text(PyFT2Font *self, PyObject *args, PyObject *k
642642
codepoints[i] = unistr[i];
643643
}
644644
} else if (PyBytes_Check(textobj)) {
645+
if (PyErr_WarnEx(
646+
PyExc_FutureWarning,
647+
"Passing bytes to FTFont.set_text is deprecated since Matplotlib "
648+
"3.4 and support will be removed in Matplotlib 3.6; pass str instead",
649+
1)) {
650+
return NULL;
651+
}
645652
size = PyBytes_Size(textobj);
646653
codepoints.resize(size);
647654
char *bytestr = PyBytes_AsString(textobj);

0 commit comments

Comments
 (0)