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
Title: ctypes.create_string_buffer fails on windows with non-BMP characters
Type: behavior Stage: resolved
Components: ctypes Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: create_unicode_buffer() fails on non-BMP strings on Windows
View: 19865
Assigned To: Nosy List: rmccampbell7
Priority: normal Keywords:

Created on 2019-07-10 05:07 by rmccampbell7, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg347600 - (view) Author: Ryan McCampbell (rmccampbell7) Date: 2019-07-10 05:07
The ctypes.create_string_buffer function uses the length of the string to create the buffer if no size is provided. Since windows wide chars are UTF-16 the buffer may actually need to be larger to store surrogate pairs. This code crashes on windows:

>>> create_unicode_buffer('\U00010000\U00010000')
ValueError: string too long
msg347601 - (view) Author: Ryan McCampbell (rmccampbell7) Date: 2019-07-10 05:22
Oops my bad, didn't realize this was already fixed
History
Date User Action Args
2022-04-11 14:59:17adminsetgithub: 81717
2019-07-10 05:22:48rmccampbell7setmessages: + msg347601
2019-07-10 05:13:07eryksunsetstatus: open -> closed
superseder: create_unicode_buffer() fails on non-BMP strings on Windows
resolution: duplicate
stage: resolved
2019-07-10 05:11:35rmccampbell7setversions: + Python 3.6
2019-07-10 05:08:33rmccampbell7settype: behavior
components: + ctypes
2019-07-10 05:07:40rmccampbell7create