Skip to content

gh-76535: Make PyUnicode_ToLowerFull and friends public #136176

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
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
Use Py_ssize_t for return value variable in unicodeobject.c
  • Loading branch information
lysnikolaou committed Jul 2, 2025
commit fff25db403f4ffc5fa56ef3b14250ee229611368
15 changes: 7 additions & 8 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -10037,9 +10037,9 @@ handle_capital_sigma(int kind, const void *data, Py_ssize_t length, Py_ssize_t i
return (final_sigma) ? 0x3C2 : 0x3C3;
}

static int
static Py_ssize_t
lower_ucs4(int kind, const void *data, Py_ssize_t length, Py_ssize_t i,
Py_UCS4 c, Py_UCS4 *mapped, int mapped_size)
Py_UCS4 c, Py_UCS4 *mapped, Py_ssize_t mapped_size)
{
/* Obscure special case. */
if (c == 0x3A3) {
Expand All @@ -10052,8 +10052,7 @@ lower_ucs4(int kind, const void *data, Py_ssize_t length, Py_ssize_t i,
static Py_ssize_t
do_capitalize(int kind, const void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *maxchar)
{
Py_ssize_t i, k = 0;
int n_res, j;
Py_ssize_t i, k = 0, n_res, j;
Py_UCS4 c, mapped[3];

c = PyUnicode_READ(kind, data, 0);
Expand Down Expand Up @@ -10081,7 +10080,7 @@ do_swapcase(int kind, const void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4

for (i = 0; i < length; i++) {
Py_UCS4 c = PyUnicode_READ(kind, data, i), mapped[3];
int n_res, j;
Py_ssize_t n_res, j;
if (Py_UNICODE_ISUPPER(c)) {
n_res = lower_ucs4(kind, data, length, i, c, mapped, Py_ARRAY_LENGTH(mapped));
}
Expand Down Expand Up @@ -10109,7 +10108,7 @@ do_upper_or_lower(int kind, const void *data, Py_ssize_t length, Py_UCS4 *res,

for (i = 0; i < length; i++) {
Py_UCS4 c = PyUnicode_READ(kind, data, i), mapped[3];
int n_res, j;
Py_ssize_t n_res, j;
if (lower)
n_res = lower_ucs4(kind, data, length, i, c, mapped, Py_ARRAY_LENGTH(mapped));
else
Expand Down Expand Up @@ -10143,7 +10142,7 @@ do_casefold(int kind, const void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4
for (i = 0; i < length; i++) {
Py_UCS4 c = PyUnicode_READ(kind, data, i);
Py_UCS4 mapped[3];
int j, n_res = PyUnicode_ToFolded(c, mapped, Py_ARRAY_LENGTH(mapped));
Py_ssize_t j, n_res = PyUnicode_ToFolded(c, mapped, Py_ARRAY_LENGTH(mapped));
assert(n_res >= 1);
for (j = 0; j < n_res; j++) {
*maxchar = Py_MAX(*maxchar, mapped[j]);
Expand All @@ -10163,7 +10162,7 @@ do_title(int kind, const void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *m
for (i = 0; i < length; i++) {
const Py_UCS4 c = PyUnicode_READ(kind, data, i);
Py_UCS4 mapped[3];
int n_res, j;
Py_ssize_t n_res, j;

if (previous_is_cased)
n_res = lower_ucs4(kind, data, length, i, c, mapped, Py_ARRAY_LENGTH(mapped));
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy