10000 gh-126004: fix positions handling in `codecs.replace_errors` by picnixz · Pull Request #127674 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-126004: fix positions handling in codecs.replace_errors #127674

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 17 commits into from
Jan 23, 2025
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
Revert "use memset instead of a for-loop"
This reverts commit d71b3a5.
  • Loading branch information
picnixz committed Jan 22, 2025
commit 39951be5d9c84171ad1e6200f09b807933c5662a
4 changes: 3 additions & 1 deletion Python/codecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,9 @@ PyObject *PyCodec_ReplaceErrors(PyObject *exc)
}
assert(slen == 0 || PyUnicode_KIND(res) == PyUnicode_2BYTE_KIND);
Py_UCS2 *outp = PyUnicode_2BYTE_DATA(res);
memset(outp, Py_UNICODE_REPLACEMENT_CHARACTER, sizeof(Py_UCS2) * slen);
for (Py_ssize_t i = 0; i < slen; ++i) {
outp[i] = Py_UNICODE_REPLACEMENT_CHARACTER;
}
assert(_PyUnicode_CheckConsistency(res, 1));
return Py_BuildValue("(Nn)", res, end);
}
Expand Down
Loading
0