-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MNT: migrate away from deprecated c-api #17680
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
MNT: migrate away from deprecated c-api #17680
Conversation
The new macros were added in py33 so all versions of Python we support have them. closes matplotlib#17629
@@ -635,11 +635,10 @@ static PyObject *PyFT2Font_set_text(PyFT2Font *self, PyObject *args, PyObject *k | |||
size_t size; | |||
|
|||
if (PyUnicode_Check(textobj)) { | |||
size = PyUnicode_GET_SIZE(textobj); | |||
size = PyUnicode_GET_LENGTH(textobj); | |||
codepoints.resize(size); |
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.
maybe simpler and more efficient to just use https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_AsUCS4 or https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_AsUCS4Copy instead of managing and additional temporay buffer ourselves?
Edit: Bah, it's too complicated given that we also support bytes input.
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.
My goal here was the minimal fix to get us off to non-deprecated API. There is some discussion of removing the deprecated macros in 3.11 so I would rather get something in ASAP.
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 seems a reasonable minimal change for 3.3.
…680-on-v3.3.x Backport PR #17680 on branch v3.3.x (MNT: migrate away from deprecated c-api)
The new macros were added in py33 so all versions of Python we support
have them.
closes #17629