classification
Title: Add the const qualifier for char and wchar_t pointers to unmodifiable strings
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2017-12-07 13:54 by serhiy.storchaka, last changed 2017-12-12 11:55 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4748 merged serhiy.storchaka, 2017-12-07 13:58
Messages (2)
msg307802 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-12-07 13:54
Py_SetProgramName() and Py_SetPythonHome() take a pointer to a string that shouldn't be changed for the duration of the program's execution. But the type of their arguments is "wchar_t *", therefore passing just a pointer to a constant static string will cause a compiler warning. The proposed PR changes the type to "const wchar_t *". This is backward compatible change.

The PR also adds the const qualifier to internal pointers that point on to unmodifiable strings. This could help to distinguish them from pointers on modifiable strings and can prevent unintentional modifications.
msg308119 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-12-12 11:55
New changeset 4ae06c5337e01bdde28bce57b6b9166ad50947e3 by Serhiy Storchaka in branch 'master':
bpo-32241: Add the const qualifire to declarations of umodifiable strings. (#4748)
https://github.com/python/cpython/commit/4ae06c5337e01bdde28bce57b6b9166ad50947e3
History
Date User Action Args
2017-12-12 11:55:32serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-12-12 11:55:06serhiy.storchakasetmessages: + msg308119
2017-12-07 13:58:48serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request4651
2017-12-07 13:54:04serhiy.storchakacreate