2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-23 05:42:30 +00:00

Merge branch 'develop'

This commit is contained in:
Stefan Seefeld
2020-11-02 00:58:26 -05:00
7 changed files with 27 additions and 13 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -60,7 +60,7 @@ call(PyObject* callable
)
{
PyObject* const result =
PyEval_CallFunction(
PyObject_CallFunction(
callable
, const_cast<char*>("(" 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.

View File

@@ -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.

View File

@@ -97,7 +97,7 @@ class override : public object
operator()() const
{
detail::method_result x(
PyEval_CallFunction(
PyObject_CallFunction(
this->ptr()
, const_cast<char*>("()")
));
@@ -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<char*>("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")")
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_fast_arg_to_python_get, nil)

View File

@@ -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<char *>(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<char*>("r"));
if (!pyfile) throw std::invalid_argument(std::string(f) + " : no such file");
python::handle<> file(pyfile);

View File

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