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: The repr of ctypes.CArgObject fails for non-ascii character
Type: behavior Stage: resolved
Components: ctypes, Extension Modules Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, belopolsky, meador.inge, miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-12-03 10:52 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 10863 merged serhiy.storchaka, 2018-12-03 10:53
PR 10983 closed miss-islington, 2018-12-06 09:16
PR 10984 merged miss-islington, 2018-12-06 09:16
PR 10985 merged miss-islington, 2018-12-06 09:40
Messages (4)
msg330931 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-03 10:52
The repr of the ctypes.CArgObject instance will fail when the value is a non-ascii character.

The code is:

        sprintf(buffer, "<cparam '%c' (%c)>",
            self->tag, self->value.c);
    ...
    return PyUnicode_FromString(buffer);

If self->value.c is out of range 0-127, buffer will contain a string not decodable with UTF-8.

There is a similar problem with non-ascii self->tag.

The following PR is purposed to fix this, but I don't know how to test it. Current tests only create CArgObject instances with tag='P' (in byref()).
msg331213 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-06 09:16
New changeset 3ffa8b9ba190101f674a0e524e482a83ed09cccd by Serhiy Storchaka in branch 'master':
bpo-35384: The repr of ctypes.CArgObject no longer fails for non-ascii character. (GH-10863)
https://github.com/python/cpython/commit/3ffa8b9ba190101f674a0e524e482a83ed09cccd
msg331215 - (view) Author: miss-islington (miss-islington) Date: 2018-12-06 09:41
New changeset f9d8b686285926c985cfe88a8392a9a497c0a916 by Miss Islington (bot) in branch '3.6':
bpo-35384: The repr of ctypes.CArgObject no longer fails for non-ascii character. (GH-10863)
https://github.com/python/cpython/commit/f9d8b686285926c985cfe88a8392a9a497c0a916
msg331219 - (view) Author: miss-islington (miss-islington) Date: 2018-12-06 09:58
New changeset f740818f3d92497c564d515a661039dc8434fc6c by Miss Islington (bot) in branch '3.7':
bpo-35384: The repr of ctypes.CArgObject no longer fails for non-ascii character. (GH-10863)
https://github.com/python/cpython/commit/f740818f3d92497c564d515a661039dc8434fc6c
History
Date User Action Args
2022-04-11 14:59:08adminsetgithub: 79565
2018-12-06 10:07:10serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-12-06 09:58:30miss-islingtonsetmessages: + msg331219
2018-12-06 09:41:18miss-islingtonsetnosy: + miss-islington
messages: + msg331215
2018-12-06 09:40:49miss-islingtonsetpull_requests: + pull_request10226
2018-12-06 09:16:49miss-islingtonsetpull_requests: + pull_request10225
2018-12-06 09:16:39miss-islingtonsetpull_requests: + pull_request10224
2018-12-06 09:16:29serhiy.storchakasetmessages: + msg331213
2018-12-03 10:53:45serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request10099
2018-12-03 10:52:28serhiy.storchakacreate