Skip to content

[3.8] closes bpo-39605: Fix some casts to not cast away const. (GH-18453)#18471

Merged
miss-islington merged 1 commit into
python:3.8from
miss-islington:backport-e6be9b5-3.8
Feb 12, 2020
Merged

[3.8] closes bpo-39605: Fix some casts to not cast away const. (GH-18453)#18471
miss-islington merged 1 commit into
python:3.8from
miss-islington:backport-e6be9b5-3.8

Conversation

@miss-islington

@miss-islington miss-islington commented Feb 12, 2020

Copy link
Copy Markdown
Contributor

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

https://bugs.python.org/issue39605

)

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>
@miss-islington

Copy link
Copy Markdown
Contributor Author

@petdance and @benjaminp: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 190433d into python:3.8 Feb 12, 2020
@miss-islington miss-islington deleted the backport-e6be9b5-3.8 branch February 12, 2020 02:47
@miss-islington

Copy link
Copy Markdown
Contributor Author

@petdance and @benjaminp: Status check is done, and it's a success ✅ .

3 similar comments
@miss-islington

Copy link
Copy Markdown
Contributor Author

@petdance and @benjaminp: Status check is done, and it's a success ✅ .

@miss-islington

Copy link
Copy Markdown
Contributor Author

@petdance and @benjaminp: Status check is done, and it's a success ✅ .

@miss-islington

Copy link
Copy Markdown
Contributor Author

@petdance and @benjaminp: Status check is done, and it's a success ✅ .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants