Skip to content

ctypes: remove use of legacy unicode API#12340

Merged
methane merged 4 commits into
python:masterfrom
methane:ctypes-legacy-api
Apr 19, 2019
Merged

ctypes: remove use of legacy unicode API#12340
methane merged 4 commits into
python:masterfrom
methane:ctypes-legacy-api

Conversation

@methane
Copy link
Copy Markdown
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
Comment thread Modules/_ctypes/_ctypes.c Outdated
Comment thread Modules/_ctypes/_ctypes.c Outdated
Comment thread Modules/_ctypes/_ctypes.c
// 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
Copy Markdown
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
Copy Markdown
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.

Comment thread Modules/_ctypes/cfield.c Outdated
@brettcannon brettcannon added the type-bug An unexpected behavior, bug, or error label Apr 17, 2019
@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.

5 participants