Navigation Menu

Skip to content
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

Closed
jimjjewett mannequin opened this issue Dec 16, 2011 · 6 comments
Closed

remove born-deprecated PyUnicode_AsUnicodeAndSize #57817

jimjjewett mannequin opened this issue Dec 16, 2011 · 6 comments

Comments

@jimjjewett
Copy link
Mannequin

jimjjewett mannequin commented Dec 16, 2011

BPO 13608
Nosy @malemburg, @loewis, @vstinner, @benjaminp, @ezio-melotti, @JimJJewett

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:

assignee = None
closed_at = <Date 2012-03-29.15:17:56.644>
created_at = <Date 2011-12-16.00:55:49.425>
labels = ['invalid', 'expert-unicode']
title = 'remove born-deprecated PyUnicode_AsUnicodeAndSize'
updated_at = <Date 2012-03-29.15:17:56.642>
user = 'https://github.com/JimJJewett'

bugs.python.org fields:

activity = <Date 2012-03-29.15:17:56.642>
actor = 'loewis'
assignee = 'none'
closed = True
closed_date = <Date 2012-03-29.15:17:56.644>
closer = 'loewis'
components = ['Unicode']
creation = <Date 2011-12-16.00:55:49.425>
creator = 'Jim.Jewett'
dependencies = []
files = []
hgrepos = []
issue_num = 13608
keywords = []
message_count = 6.0
messages = ['149585', '156845', '156853', '156887', '156897', '157057']
nosy_count = 6.0
nosy_names = ['lemburg', 'loewis', 'vstinner', 'benjamin.peterson', 'ezio.melotti', 'Jim.Jewett']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue13608'
versions = ['Python 3.3']

@jimjjewett
Copy link
Mannequin Author

jimjjewett mannequin commented Dec 16, 2011

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.

@jimjjewett jimjjewett mannequin added the topic-unicode label Dec 16, 2011
@jimjjewett
Copy link
Mannequin Author

jimjjewett mannequin commented Mar 26, 2012

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.

@benjaminp
Copy link
Contributor

It could be made an internal function.

@vstinner
Copy link
Member

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.

@malemburg
Copy link
Member

STINNER Victor wrote:

STINNER Victor <victor.stinner@gmail.com> added the comment:

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.

Could you please clarify what you actually intend to do ? Which
function do you want to remove and why ?

The title and description of this ticket don't match :-)

@loewis
Copy link
Mannequin

loewis mannequin commented Mar 29, 2012

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.

@loewis loewis mannequin closed this as completed Mar 29, 2012
@loewis loewis mannequin added the invalid label Mar 29, 2012
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants