diff --git a/Python/fileutils.c b/Python/fileutils.c index 68d24bc6b93465..44409d933fa875 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -55,8 +55,9 @@ int _Py_open_cloexec_works = -1; // mbstowcs() and mbrtowc() errors static const size_t DECODE_ERROR = ((size_t)-1); +#ifdef HAVE_MBRTOWC static const size_t INCOMPLETE_CHARACTER = (size_t)-2; - +#endif static int get_surrogateescape(_Py_error_handler errors, int *surrogateescape) @@ -129,7 +130,7 @@ is_valid_wide_char(wchar_t ch) // Reject lone surrogate characters return 0; } - if (ch > MAX_UNICODE) { + if (sizeof(ch) > 2 && ch > MAX_UNICODE) { // bpo-35883: Reject characters outside [U+0000; U+10ffff] range. // The glibc mbstowcs() UTF-8 decoder does not respect the RFC 3629, // it creates characters outside the [U+0000; U+10ffff] range: