[3.8] closes bpo-39605: Fix some casts to not cast away const. (GH-18453)#18471
Merged
Merged
Conversation
) 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 (cherry picked from commit e6be9b5) Co-authored-by: Andy Lester <andy@petdance.com>
benjaminp
approved these changes
Feb 12, 2020
Contributor
Author
|
@petdance and @benjaminp: Status check is done, and it's a success ✅ . |
Contributor
Author
|
@petdance and @benjaminp: Status check is done, and it's a success ✅ . |
3 similar comments
Contributor
Author
|
@petdance and @benjaminp: Status check is done, and it's a success ✅ . |
Contributor
Author
|
@petdance and @benjaminp: Status check is done, and it's a success ✅ . |
Contributor
Author
|
@petdance and @benjaminp: Status check is done, and it's a success ✅ . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
or, Removing the cast entirely, because it's not necessary (but probably was at one time), as in:
These changes will not change code, but they will make it much easier to check for errors in consts
(cherry picked from commit e6be9b5)
Co-authored-by: Andy Lester andy@petdance.com
https://bugs.python.org/issue39605