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
remove born-deprecated PyUnicode_AsUnicodeAndSize #57817
Comments
In reviewing bpo-13604 (aligning PEP-393 with the implementation) Victor Stinner noticed that PyUnicode_AsUnicodeAndSize is new in 3.3, but that it is already deprecated (because it relies on the old PyUnicode type). This born-deprecated function is just a shortcut for PyUnicode_AsUnicode plus PyUnicode_GET_SIZE, and should be removed. |
It is now a useful function, as PyUnicode_AsUnicode defers to it. It is still born-deprecated, but that may be unavoidable, as all use of the wstr format is deprecated. |
It could be made an internal function. |
The Py_UNICODE* type is deprecated but since Python 3.3, Py_UNICODE=wchar_t and wchar_t* is a common type on Windows. PyUnicode_AsUnicodeAndSize() is used to encode Python strings to call Windows functions. PyUnicode_AsUnicodeAndSize() is preferred over PyUnicode_AsWideCharString() because PyUnicode_AsWideCharString() stores the result in the Unicode string and the Unicode string releases the memory automatically later. Calling PyUnicode_AsWideCharString() twice on the same string avoids also the need of encoding the string twice because the result is cached. I proposed to add a new function using wchar_*t and storing the result in the Unicode string, but the idea was rejected. I don't remember why. |
STINNER Victor wrote:
Could you please clarify what you actually intend to do ? Which The title and description of this ticket don't match :-) |
I fail to see the issue. Even though the function is born-deprecated, there are valid use cases for it, even for new code (see http://www.python.org/dev/peps/pep-0393/#deprecations-removals-and-incompatibilities). Closing the issue as invalid. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: