Issue 30863: Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() - Python tracker

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.

classification
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2017-07-06 07:53 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2599 merged serhiy.storchaka, 2017-07-06 07:56
Messages (5)
msg297813 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-07-06 07:53
Since Python 3.3 PyUnicode_AsUnicodeAndSize() is deprecated in favour of PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). But the latter two are implemented using PyUnicode_AsUnicodeAndSize(). This prevents adding the deprecation compiler warning for PyUnicode_AsUnicodeAndSize(). Other side effect -- PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() cache the wchar_t* representation of the PyUnicode object increasing its memory consumption.

Proposed patch reimplements PyUnicode_AsWideChar(), PyUnicode_AsWideCharString() and PyUnicode_AsUnicodeAndSize() using two common helper functions. PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() no longer cache the wchar_t* representation.
msg322252 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-23 20:10
Victor already wrote similar patch in issue22323.
msg322265 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-23 21:42
Would it be possible to remove the wchar_t* cache?
msg322268 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-23 22:00
Only after removing PyUnicode_AsUnicodeAndSize() and related PyArg_ParseTuple codes.
msg328340 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-23 19:58
New changeset c46db9232f1a6e0e3c33053549d03d4335db9dca by Serhiy Storchaka in branch 'master':
bpo-30863: Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). (GH-2599)
https://github.com/python/cpython/commit/c46db9232f1a6e0e3c33053549d03d4335db9dca