New submission from Stephen Kelly <steve...@gmail.com>:

When using C++ to extend python, one may use PyGetSetDef for example:


static PyGetSetDef Noddy_getseters[] = {
    {"first",
     (getter)Noddy_getfirst, (setter)Noddy_setfirst,
     "first name",
     NULL},
    {"last",
     (getter)Noddy_getlast, (setter)Noddy_setlast,
     "last name",
     NULL},
    {NULL}  /* Sentinel */
};

However, in C++ implicit conversion from const char* to char* is deprecated 
since C++98, and is a removed conversion in C++11.

 https://godbolt.org/g/sswUKM

GCC/Clang warn about this, and MSVC in conformance mode (/permissive-) errors 
on it.

PyGetSetDef and similar APIs should use const char* instead of char* for 
members such as `name`.

----------
components: Library (Lib)
messages: 308316
nosy: steveire
priority: normal
severity: normal
status: open
title: C API should use 'const char *' instead of 'char *'
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32325>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to