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 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 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) 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); 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); } }