]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-124008: Fix calculation of the number of written bytes for the Windows...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 30 Nov 2024 09:16:45 +0000 (10:16 +0100)
committerGitHub <noreply@github.com>
Sat, 30 Nov 2024 09:16:45 +0000 (09:16 +0000)
commitd2d1055129df2184e11947c25380da041959c347
treefb5fbe41ddd0a820638a512360aac4e8af3a16b8
parent089d70614e6dcb8c27a537a03ac3e701960ba629
[3.13] gh-124008: Fix calculation of the number of written bytes for the Windows console (GH-124059) (GH-127325)

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 3cf83d91a5baf3600dd60f7aaaf4fb6d73c4b8a9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/test_winconsoleio.py
Misc/NEWS.d/next/Library/2024-09-13-18-24-27.gh-issue-124008.XaiPQx.rst [new file with mode: 0644]
Modules/_io/winconsoleio.c