From f218549afc7845ccc4168ceecb1f94ff1c58468a Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 14 Apr 2025 21:59:07 +0300 Subject: [PATCH] =?utf8?q?[3.13]=20gh-124476:=20Fix=20decoding=20from=20th?= =?utf8?q?e=20locale=20encoding=20in=20the=20C.UTF-8=20locale=20(GH-132477?= =?utf8?q?)=20(=D0=9F=D0=A0-132528)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit (cherry picked from commit 102f825c5112cbe6985edc0971822b07bd778135) --- .../2025-04-13-17-18-01.gh-issue-124476.fvGfQ7.rst | 1 + Python/fileutils.c | 10 +--------- 2 files changed, 2 insertions(+), 9 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2025-04-13-17-18-01.gh-issue-124476.fvGfQ7.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2025-04-13-17-18-01.gh-issue-124476.fvGfQ7.rst b/Misc/NEWS.d/next/Core and Builtins/2025-04-13-17-18-01.gh-issue-124476.fvGfQ7.rst new file mode 100644 index 000000000000..be0ecee95ded --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2025-04-13-17-18-01.gh-issue-124476.fvGfQ7.rst @@ -0,0 +1 @@ +Fix decoding from the locale encoding in the C.UTF-8 locale. diff --git a/Python/fileutils.c b/Python/fileutils.c index 9529b14d377c..921500bfef1d 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -523,15 +523,7 @@ decode_current_locale(const char* arg, wchar_t **wstr, size_t *wlen, break; } - if (converted == INCOMPLETE_CHARACTER) { - /* Incomplete character. This should never happen, - since we provide everything that we have - - unless there is a bug in the C library, or I - misunderstood how mbrtowc works. */ - goto decode_error; - } - - if (converted == DECODE_ERROR) { + if (converted == DECODE_ERROR || converted == INCOMPLETE_CHARACTER) { if (!surrogateescape) { goto decode_error; } -- 2.47.3