Skip to content

ctypes: remove use of legacy unicode API #12340

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

Merged
merged 4 commits into from
Apr 19, 2019

Conversation

methane
Copy link
Member

@methane methane commented Mar 15, 2019

PyUnicode_AsUnicodeAndSize() -> PyUnicode_AsWideChar()

PyUnicode_AsUnicodeAndSize() -> PyUnicode_AsWideChar()
@methane methane requested a review from abalkin March 15, 2019 11:45
// PyUnicode_AsWideChar() returns number of wchars including trailing NUL,
// when it is called with NULL.
if ((size_t)len-1 > self->b_size/sizeof(wchar_t)) {
PyErr_SetString(PyExc_ValueError, "string too long");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth providing in the exception message the provided length and what the max length actually is?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe yes. But this file has similar codes which are not relating to wchar_t APIs. ("bytes string too long").
I want to keep this pull request simple.

@brettcannon brettcannon added the type-bug An unexpected behavior, bug, or error label Apr 17, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-Authored-By: methane <[email protected]>
@methane methane merged commit 9d062d6 into python:master Apr 19, 2019
@methane methane deleted the ctypes-legacy-api branch April 19, 2019 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip issue skip news type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants