X Tutup
Skip to content

[3.13] gh-124008: Fix calculation of the number of written bytes for the Windows console (GH-124059)#127325

Merged
serhiy-storchaka merged 2 commits intopython:3.13from
miss-islington:backport-3cf83d9-3.13
Nov 30, 2024
Merged

[3.13] gh-124008: Fix calculation of the number of written bytes for the Windows console (GH-124059)#127325
serhiy-storchaka merged 2 commits intopython:3.13from
miss-islington:backport-3cf83d9-3.13

Conversation

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Nov 27, 2024

Since MultiByteToWideChar()/WideCharToMultiByte() is not reversible if
the data contains invalid UTF-8 sequences, use binary search to
calculate the number of written bytes from the number of written
characters.

Also fix writing incomplete UTF-8 sequences.

Also fix handling of memory allocation failures.
(cherry picked from commit 3cf83d9)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

…he Windows console (pythonGH-124059)

Since MultiByteToWideChar()/WideCharToMultiByte() is not reversible if
the data contains invalid UTF-8 sequences, use binary search to
calculate the number of written bytes from the number of written
characters.

Also fix writing incomplete UTF-8 sequences.

Also fix handling of memory allocation failures.
(cherry picked from commit 3cf83d9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@serhiy-storchaka serhiy-storchaka merged commit d2d1055 into python:3.13 Nov 30, 2024
@miss-islington miss-islington deleted the backport-3cf83d9-3.13 branch January 2, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup