8000 gh-110289: C API: Add PyUnicode_EqualToUTF8() function by serhiy-storchaka · Pull Request #110297 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-110289: C API: Add PyUnicode_EqualToUTF8() function #110297

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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
serhiy-storchaka and vstinner authored Oct 4, 2023
commit c55f9ac784a417bc615f2335c813c0e39437e0fd
2 changes: 1 addition & 1 deletion Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ They all return ``NULL`` or ``-1`` if an exception occurs.
Compare a Unicode object with a UTF-8 encoded C string and return true
if they are equal and false otherwise.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Compare a Unicode object with a UTF-8 encoded C string and return true
if they are equal and false otherwise.
Compare a Unicode object with a UTF-8 encoded C string and return non-zero
if they are equal or 0 otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks to me, that "return true" is more often used than "return non-zero". In this case it is more accurate, because it always returns 1, not other non-zero value. Perhaps other functions which return non-zero was a macro that returned not 1 (something like (arg->flags & FLAG))?

If the Unicode object contains null or surrogate characters or
the C string not encoded to UTF-8 return false.
the C string is not encoded to UTF-8 return 0.

This function does not raise exceptions.

Expand Down
0