From 11ad5a1a6eed45ca95908152fbc1fb09fbbc4961 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 28 Apr 2024 11:36:26 +0530 Subject: [PATCH] Fix deprecation warning from Py_DefaultFileystemEncoding --- src/calibre/utils/icu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/icu.c b/src/calibre/utils/icu.c index c67449018e..58053bb520 100644 --- a/src/calibre/utils/icu.c +++ b/src/calibre/utils/icu.c @@ -1231,9 +1231,16 @@ icu_set_filesystem_encoding(PyObject *self, PyObject *args) { char *encoding; if (!PyArg_ParseTuple(args, "s:setfilesystemencoding", &encoding)) return NULL; +#if PY_VERSION_HEX < 0x03012000 + // The nitwits at Python deprecated this in 3.12 claiming we should use + // PyConfig.filesystem_encoding instead. But that can only be used if we + // control the interpreter, which we do not in Linux distro builds. Sigh. + // Well, if this causes issues we just continue to tell people not to use + // Linux distro builds. On frozen aka non-distro builds we set + // PyPreConfig.utf8_mode = 1 which supposedly sets this to utf-8 anyway. Py_FileSystemDefaultEncoding = strdup(encoding); +#endif Py_RETURN_NONE; - } // }}}