From b4fbf1840bb581a12617296b6ec2b0462906a23a Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Thu, 15 Oct 2020 11:25:18 -0400 Subject: [PATCH 1/5] Fix appveyor builds. --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index c8205eae..ffcd7e3b 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -30,7 +30,7 @@ environment: PYTHON: C:\\Python36-x64 PYTHON_VERSION: 3.6.x PYTHON_ARCH: 64 - MSVC: 16.6.5 + MSVC: 16.7.4 ARCH: x86_64 BOOST_PREFIX: C:\Libraries\boost_1_73_0 From 944fa075b321cf53a972dfd0e9bab11cc194ee15 Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Wed, 14 Oct 2020 13:54:24 -0500 Subject: [PATCH 2/5] Stop using deprecated API calls (python-3.9) #319 --- include/boost/python/call.hpp | 4 ++-- include/boost/python/call_method.hpp | 2 +- include/boost/python/override.hpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/python/call.hpp b/include/boost/python/call.hpp index 5d2d7d23..c057ee9a 100644 --- a/include/boost/python/call.hpp +++ b/include/boost/python/call.hpp @@ -60,7 +60,7 @@ call(PyObject* callable ) { PyObject* const result = - PyEval_CallFunction( + PyObject_CallFunction( callable , const_cast("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")") BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil) @@ -69,7 +69,7 @@ call(PyObject* callable // This conversion *must not* be done in the same expression as // the call, because, in the special case where the result is a // reference a Python object which was created by converting a C++ - // argument for passing to PyEval_CallFunction, its reference + // argument for passing to PyObject_CallFunction, its reference // count will be 2 until the end of the full expression containing // the conversion, and that interferes with dangling // pointer/reference detection. diff --git a/include/boost/python/call_method.hpp b/include/boost/python/call_method.hpp index 410f6682..424077ea 100644 --- a/include/boost/python/call_method.hpp +++ b/include/boost/python/call_method.hpp @@ -69,7 +69,7 @@ call_method(PyObject* self, char const* name // This conversion *must not* be done in the same expression as // the call, because, in the special case where the result is a // reference a Python object which was created by converting a C++ - // argument for passing to PyEval_CallFunction, its reference + // argument for passing to PyObject_CallFunction, its reference // count will be 2 until the end of the full expression containing // the conversion, and that interferes with dangling // pointer/reference detection. diff --git a/include/boost/python/override.hpp b/include/boost/python/override.hpp index 39714257..b631226f 100644 --- a/include/boost/python/override.hpp +++ b/include/boost/python/override.hpp @@ -97,7 +97,7 @@ class override : public object operator()() const { detail::method_result x( - PyEval_CallFunction( + PyObject_CallFunction( this->ptr() , const_cast("()") )); @@ -132,7 +132,7 @@ detail::method_result operator()( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a) ) const { detail::method_result x( - PyEval_CallFunction( + PyObject_CallFunction( this->ptr() , const_cast("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")") BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_fast_arg_to_python_get, nil) From 9ad5298d0be817ebce482b6b0e4b79f3cf6a1b73 Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Mon, 2 Mar 2020 08:29:52 -0600 Subject: [PATCH 3/5] Use python macros to stay on public API for new pythons --- src/wrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wrapper.cpp b/src/wrapper.cpp index f8feaef9..8b1b8847 100644 --- a/src/wrapper.cpp +++ b/src/wrapper.cpp @@ -25,7 +25,7 @@ namespace detail if ( PyMethod_Check(m.get()) - && ((PyMethodObject*)m.get())->im_self == this->m_self + && PyMethod_GET_SELF(m.get()) == this->m_self && class_object->tp_dict != 0 ) { @@ -34,7 +34,7 @@ namespace detail } - if (borrowed_f != ((PyMethodObject*)m.get())->im_func) + if (borrowed_f != PyMethod_GET_FUNCTION(m.get())) return override(m); } } From d9f06052e28873037db7f98629bce72182a42410 Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Mon, 29 Jun 2020 10:51:58 -0500 Subject: [PATCH 4/5] Convert Python 3.1+ to use public C API for filenames --- src/exec.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index 171c6f41..b2eabe59 100644 --- a/src/exec.cpp +++ b/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"); -#elif PY_VERSION_HEX >= 0x03000000 +#if PY_VERSION_HEX >= 0x03010000 + // Let python manage any UTF bits to avoid potential incompatibilities. PyObject *fo = Py_BuildValue("s", f); - FILE *fs = _Py_fopen(fo, "r"); + 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"); // 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); From f1320bf30b4887aff28b9fc67b98f6f8be8c3684 Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Tue, 13 Oct 2020 13:34:52 -0500 Subject: [PATCH 5/5] Add pypy3 to TravisCI matrix --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index ef7828c6..657386bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,20 +28,26 @@ jobs: env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++98 - os: linux env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++11 + - os: linux + env: CXX=g++ PYTHON=pypy3 CXXFLAGS=-std=c++11 - os: osx env: CXX=clang++ PYTHON=python CXXFLAGS=-std=c++11 - env: PYTHON=python DOC=1 allow_failures: + - os: linux + env: CXX=g++ PYTHON=pypy3 CXXFLAGS=-std=c++11 - os: osx addons: apt: sources: - ubuntu-toolchain-r-test + - pypy packages: - gcc - g++ - clang + - pypy3-dev - python3-pip - python-numpy - python-sphinx