This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年12月16日 00:55 by Jim.Jewett, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (6) | |||
|---|---|---|---|
| msg149585 - (view) | Author: Jim Jewett (Jim.Jewett) * (Python triager) | Date: 2011年12月16日 00:55 | |
In reviewing issue 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. |
|||
| msg156845 - (view) | Author: Jim Jewett (Jim.Jewett) * (Python triager) | Date: 2012年03月26日 18:31 | |
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. |
|||
| msg156853 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2012年03月26日 18:47 | |
It could be made an internal function. |
|||
| msg156887 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2012年03月27日 01:02 | |
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. |
|||
| msg156897 - (view) | Author: Marc-Andre Lemburg (lemburg) * (Python committer) | Date: 2012年03月27日 07:22 | |
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 :-) |
|||
| msg157057 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2012年03月29日 15:17 | |
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. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:24 | admin | set | github: 57817 |
| 2012年03月29日 15:17:56 | loewis | set | status: open -> closed nosy: + loewis messages: + msg157057 resolution: not a bug |
| 2012年03月27日 07:22:15 | lemburg | set | nosy:
+ lemburg messages: + msg156897 |
| 2012年03月27日 01:02:47 | vstinner | set | nosy:
+ vstinner messages: + msg156887 |
| 2012年03月26日 18:47:27 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages: + msg156853 |
| 2012年03月26日 18:31:44 | Jim.Jewett | set | messages: + msg156845 |
| 2011年12月16日 00:55:49 | Jim.Jewett | create | |