10000 Add private _PyUnicode_AsUTF8() function by serhiy-storchaka · Pull Request #111957 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Add private _PyUnicode_AsUTF8() function #111957

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
merged 2 commits into from
Nov 10, 2023

Conversation

serhiy-storchaka
Copy link
Member

Like PyUnicode_AsUTF8(), but check for embedded null characters.

It is only used in two places, but I am planning to use it more.

Since it is a private function, I do not expect a hot discussion about it. I added similar variants of PyUnicode_AsUnicode() in the past.

Like PyUnicode_AsUTF8(), but check for embedded null characters.
@vstinner
Copy link
Member

Can you rename it to _PyUnicode_AsUTF8NoNUL() (or any other name)? A single underscore to distinguish it from PyUnicode_AsUTF8() is not enough.

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@erlend-aasland erlend-aasland removed their request for review November 10, 2023 18:52
@serhiy-storchaka serhiy-storchaka merged commit 771bd3c into python:main Nov 10, 2023
@serhiy-storchaka serhiy-storchaka deleted the _PyUnicode_AsUTF8 branch November 10, 2023 19:31
@serhiy-storchaka serhiy-storchaka added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Nov 10, 2023
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 771bd3c94a366547e0c3451a72a430e1132c1ac1 3.11

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 10, 2023
Like PyUnicode_AsUTF8(), but check for embedded null characters.
(cherry picked from commit 771bd3c)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app
Copy link
bedevere-app bot commented Nov 10, 2023

GH-111975 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Nov 10, 2023
@serhiy-storchaka
Copy link
Member Author

I will perhaps backport this, because some bugfixes need to check for embedded NUL. It is simpler to replace PyUnicode_AsUTF8() with a new function than to add all these checks manually.

@serhiy-storchaka
Copy link
Member Author

Damn, the guard against ABI changes does not allow this.

@serhiy-storchaka serhiy-storchaka removed the needs backport to 3.11 only security fixes label Nov 10, 2023
@vstinner
Copy link
Member

Even if the function is not exported? Using the right command, you can ignore this ABI warning, but regenerating ABI data.

aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Like PyUnicode_AsUTF8(), but check for embedded null characters.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Like PyUnicode_AsUTF8(), but check for embedded null characters.
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.

2 participants
0