[New-bugs-announce] [issue28761] Add the const qualifier to fields name and doc of public structs

Serhiy Storchaka report at bugs.python.org
Mon Nov 21 04:40:15 EST 2016


New submission from Serhiy Storchaka:

Proposed patch makes the fields name and doc of structures PyMemberDef, PyGetSetDef, PyStructSequence_Field, PyStructSequence_Desc, and wrapperbase being of type "const char *" rather of "char *".

These structures often are initialized as static variables and name and doc fields are initialized from literal strings. These fields are always refer to constant string literal, NULL, or readonly UTF8 representation of a Unicode object. They are never refer to mutable data. Changing the data referred by these pointers is an error. Adding the const qualifier makes clear that this is an immutable data.

This change may need some changes in third-party code. But it needs to change only one line in CPython sources, and I believe that most third-party projects don't need any changes at all.

----------
components: Interpreter Core
files: const-name-and-doc-fields.patch
keywords: patch
messages: 281340
nosy: ncoghlan, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Add the const qualifier to fields name and doc of public structs
type: enhancement
versions: Python 3.7
Added file: http://bugs.python.org/file45581/const-name-and-doc-fields.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28761>
_______________________________________


More information about the New-bugs-announce mailing list