Skip to content

bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode data. #19345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Apr 3, 2020

@skrah
Copy link
Contributor

skrah commented Apr 3, 2020

The _decimal changes look fine, I'm not going to review the rest because it's so large.

@serhiy-storchaka
Copy link
Member Author

I made PyUnicode_DATA, PyUnicode_1BYTE_DATA, PyUnicode_2BYTE_DATA and PyUnicode_4BYTE_DATA returning a pointer to const. Then I added consts and casts discarding const until all compiled. Then I removed changes to these macros and casts discarding const, and what it were left is in this PR.

The only nontrivial changes -- replacing PyUnicode_WRITE with known kind in codecs.c. It is a microoptimization.

@serhiy-storchaka
Copy link
Member Author

serhiy-storchaka commented Apr 3, 2020

Actually, 80% of the PR was written several months ago. Now I just renewed it using an opportunity of bpo-39943.

@serhiy-storchaka serhiy-storchaka merged commit cd8295f into python:master Apr 11, 2020
@serhiy-storchaka serhiy-storchaka deleted the constify-unicode-data1 branch April 11, 2020 07:48
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.

4 participants