]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
closes bpo-39605: Fix some casts to not cast away const. (GH-18453)
authorAndy Lester <andy@petdance.com>
Wed, 12 Feb 2020 02:28:35 +0000 (20:28 -0600)
committerGitHub <noreply@github.com>
Wed, 12 Feb 2020 02:28:35 +0000 (18:28 -0800)
commite6be9b59a911626d6597fe148c32f0342bd2bd24
treef5912158983ae1a5adcdc2131c183d09012588f8
parent029e8401b7741cc0964b5f38d2c2264749dbff6b
closes bpo-39605: Fix some casts to not cast away const. (GH-18453)

gcc -Wcast-qual turns up a number of instances of casting away constness of pointers. Some of these can be safely modified, by either:

Adding the const to the type cast, as in:

-    return _PyUnicode_FromUCS1((unsigned char*)s, size);
+    return _PyUnicode_FromUCS1((const unsigned char*)s, size);

or, Removing the cast entirely, because it's not necessary (but probably was at one time), as in:

-    PyDTrace_FUNCTION_ENTRY((char *)filename, (char *)funcname, lineno);
+    PyDTrace_FUNCTION_ENTRY(filename, funcname, lineno);

These changes will not change code, but they will make it much easier to check for errors in consts
Modules/_io/textio.c
Objects/bytes_methods.c
Objects/memoryobject.c
Objects/stringlib/asciilib.h
Objects/stringlib/codecs.h
Objects/stringlib/find_max_char.h
Objects/unicodeobject.c
Python/ceval.c
Python/marshal.c
Python/pyhash.c
Python/sysmodule.c