From 107ed94d8f4f716ff09f8412eafa2b5b1d6bba1b Mon Sep 17 00:00:00 2001 From: Aapo Date: Wed, 23 Dec 2020 01:03:16 +0200 Subject: [PATCH] CXX, Objects.hxx: Python 3.9 Unicode compilation warning fixes suggested by wmayer on the FC forum. --- src/CXX/Python3/Objects.hxx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/CXX/Python3/Objects.hxx b/src/CXX/Python3/Objects.hxx index 5d15b4b2de..08f77df6c1 100644 --- a/src/CXX/Python3/Objects.hxx +++ b/src/CXX/Python3/Objects.hxx @@ -2135,13 +2135,20 @@ namespace Py // Queries virtual size_type size() const { - return PyUnicode_GET_SIZE( ptr() ); + return PyUnicode_GetLength( ptr() ); + } + +#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9 + const Py_UNICODE *unicode_data() const + { + return PyUnicode_AS_UNICODE( ptr() ); } unicodestring as_unicodestring() const { - return unicodestring( PyUnicode_AS_UNICODE( ptr() ), PyUnicode_GET_SIZE( ptr() ) ); + return unicodestring( unicode_data(), PyUnicode_GetLength( ptr() ) ); } +#endif operator std::string() const { @@ -2154,11 +2161,6 @@ namespace Py Bytes b( encode( encoding, error ) ); return b.as_std_string(); } - - const Py_UNICODE *unicode_data() const - { - return PyUnicode_AS_UNICODE( ptr() ); - } }; // ==================================================