bpo-39605: Fix some casts to not cast away const#18453
Merged
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18453 +/- ##
==========================================
- Coverage 82.20% 82.11% -0.09%
==========================================
Files 1957 1954 -3
Lines 589324 583606 -5718
Branches 44428 44428
==========================================
- Hits 484430 479255 -5175
+ Misses 95233 94705 -528
+ Partials 9661 9646 -15
Continue to review full report at Codecov.
|
Contributor
|
Thanks @petdance for the PR, and @benjaminp for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
|
GH-18471 is a backport of this pull request to the 3.8 branch. |
miss-islington
added a commit
that referenced
this pull request
Feb 12, 2020
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>
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-qualturns up a number of instances of casting away constness of pointers. Some of these can be safely modified, by either:Adding the
constto 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.
https://bugs.python.org/issue39605