From e76bc46d2c81e8ea38069c8bed9fb166c8e43d07 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 13 Apr 2025 17:18:06 +0300 Subject: [PATCH 1/2] gh-124476: Fix decoding from the locale encoding on C.UTF-8 locale. --- .../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 00000000000000..1c581320c056e4 --- /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 on C.UTF-8 locale. diff --git a/Python/fileutils.c b/Python/fileutils.c index 95b64ed76fb974..78603d40704f14 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -528,15 +528,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; } From 8fd4223dbc36d401f6c695e388eb77085515895d Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 14 Apr 2025 15:13:21 +0300 Subject: [PATCH 2/2] Update Misc/NEWS.d/next/Core_and_Builtins/2025-04-13-17-18-01.gh-issue-124476.fvGfQ7.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- .../2025-04-13-17-18-01.gh-issue-124476.fvGfQ7.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 1c581320c056e4..be0ecee95ded39 100644 --- 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 @@ -1 +1 @@ -Fix decoding from the locale encoding on C.UTF-8 locale. +Fix decoding from the locale encoding in the C.UTF-8 locale.