From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- .../boost-python-use-public-api-for-filename.patch | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 cmake/modules/boost-python-use-public-api-for-filename.patch (limited to 'cmake/modules/boost-python-use-public-api-for-filename.patch') diff --git a/cmake/modules/boost-python-use-public-api-for-filename.patch b/cmake/modules/boost-python-use-public-api-for-filename.patch new file mode 100644 index 000000000..899a02384 --- /dev/null +++ b/cmake/modules/boost-python-use-public-api-for-filename.patch @@ -0,0 +1,38 @@ +From d9f06052e28873037db7f98629bce72182a42410 Mon Sep 17 00:00:00 2001 +From: Pat Riehecky +Date: Mon, 29 Jun 2020 10:51:58 -0500 +Subject: [PATCH] Convert Python 3.1+ to use public C API for filenames +--- + src/exec.cpp | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) +diff --git a/src/exec.cpp b/src/exec.cpp +index 171c6f4189..b2eabe59f6 100644 +--- a/src/boost/libs/python/src/exec.cpp ++++ b/src/boost/libs/python/src/exec.cpp +@@ -104,14 +104,22 @@ object BOOST_PYTHON_DECL exec_file(char const *filename, object global, object l + if (local.is_none()) local = global; + // should be 'char const *' but older python versions don't use 'const' yet. + char *f = const_cast(filename); +- // Let python open the file to avoid potential binary incompatibilities. +-#if PY_VERSION_HEX >= 0x03040000 +- FILE *fs = _Py_fopen(f, "r"); ++#if PY_VERSION_HEX >= 0x03010000 ++ // Let python manage any UTF bits to avoid potential incompatibilities. ++ PyObject *fo = Py_BuildValue("s", f); ++ PyObject *fb = Py_None; ++ PyUnicode_FSConverter(fo, &fb); ++ f = PyBytes_AsString(fb); ++ FILE *fs = fopen(f, "r"); ++ Py_DECREF(fo); ++ Py_DECREF(fb); + #elif PY_VERSION_HEX >= 0x03000000 ++ // Let python open the file to avoid potential binary incompatibilities. + PyObject *fo = Py_BuildValue("s", f); +- FILE *fs = _Py_fopen(fo, "r"); ++ FILE *fs = _Py_fopen(fo, "r"); // Private CPython API + Py_DECREF(fo); + #else ++ // Let python open the file to avoid potential binary incompatibilities. + PyObject *pyfile = PyFile_FromString(f, const_cast("r")); + if (!pyfile) throw std::invalid_argument(std::string(f) + " : no such file"); + python::handle<> file(pyfile); -- cgit v1.2.3