Skip to content

Commit cc97326

Browse files
committed
Merge branch 'develop'
2 parents ec402ea + f1320bf commit cc97326

File tree

7 files changed

+26
-12
lines changed

7 files changed

+26
-12
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ environment:
3030
PYTHON: C:\\Python36-x64
3131
PYTHON_VERSION: 3.6.x
3232
PYTHON_ARCH: 64
33-
MSVC: 16.6.5
33+
MSVC: 16.7.4
3434
ARCH: x86_64
3535
BOOST_PREFIX: C:\Libraries\boost_1_73_0
3636

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,26 @@ jobs:
2828
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++98
2929
- os: linux
3030
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++11
31+
- os: linux
32+
env: CXX=g++ PYTHON=pypy3 CXXFLAGS=-std=c++11
3133
- os: osx
3234
env: CXX=clang++ PYTHON=python CXXFLAGS=-std=c++11
3335
- env: PYTHON=python DOC=1
3436
allow_failures:
37+
- os: linux
38+
env: CXX=g++ PYTHON=pypy3 CXXFLAGS=-std=c++11
3539
- os: osx
3640

3741
addons:
3842
apt:
3943
sources:
4044
- ubuntu-toolchain-r-test
45+
- pypy
4146
packages:
4247
- gcc
4348
- g++
4449
- clang
50+
- pypy3-dev
4551
- python3-pip
4652
- python-numpy
4753
- python-sphinx

include/boost/python/call.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ call(PyObject* callable
6060
)
6161
{
6262
PyObject* const result =
63-
PyEval_CallFunction(
63+
PyObject_CallFunction(
6464
callable
6565
, const_cast<char*>("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")")
6666
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
@@ -69,7 +69,7 @@ call(PyObject* callable
6969
// This conversion *must not* be done in the same expression as
7070
// the call, because, in the special case where the result is a
7171
// reference a Python object which was created by converting a C++
72-
// argument for passing to PyEval_CallFunction, its reference
72+
// argument for passing to PyObject_CallFunction, its reference
7373
// count will be 2 until the end of the full expression containing
7474
// the conversion, and that interferes with dangling
7575
// pointer/reference detection.

include/boost/python/call_method.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ call_method(PyObject* self, char const* name
6969
// This conversion *must not* be done in the same expression as
7070
// the call, because, in the special case where the result is a
7171
// reference a Python object which was created by converting a C++
72-
// argument for passing to PyEval_CallFunction, its reference
72+
// argument for passing to PyObject_CallFunction, its reference
7373
// count will be 2 until the end of the full expression containing
7474
// the conversion, and that interferes with dangling
7575
// pointer/reference detection.

include/boost/python/override.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class override : public object
9797
operator()() const
9898
{
9999
detail::method_result x(
100-
PyEval_CallFunction(
100+
PyObject_CallFunction(
101101
this->ptr()
102102
, const_cast<char*>("()")
103103
));
@@ -132,7 +132,7 @@ detail::method_result
132132
operator()( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a) ) const
133133
{
134134
detail::method_result x(
135-
PyEval_CallFunction(
135+
PyObject_CallFunction(
136136
this->ptr()
137137
, const_cast<char*>("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")")
138138
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_fast_arg_to_python_get, nil)

src/exec.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,22 @@ object BOOST_PYTHON_DECL exec_file(char const *filename, object global, object l
104104
if (local.is_none()) local = global;
105105
// should be 'char const *' but older python versions don't use 'const' yet.
106106
char *f = const_cast<char *>(filename);
107-
// Let python open the file to avoid potential binary incompatibilities.
108-
#if PY_VERSION_HEX >= 0x03040000
109-
FILE *fs = _Py_fopen(f, "r");
107+
#if PY_VERSION_HEX >= 0x03010000
108+
// Let python manage any UTF bits to avoid potential incompatibilities.
109+
PyObject *fo = Py_BuildValue("s", f);
110+
PyObject *fb = Py_None;
111+
PyUnicode_FSConverter(fo, &fb);
112+
f = PyBytes_AsString(fb);
113+
FILE *fs = fopen(f, "r");
114+
Py_DECREF(fo);
115+
Py_DECREF(fb);
110116
#elif PY_VERSION_HEX >= 0x03000000
117+
// Let python open the file to avoid potential binary incompatibilities.
111118
PyObject *fo = Py_BuildValue("s", f);
112-
FILE *fs = _Py_fopen(fo, "r");
119+
FILE *fs = _Py_fopen(fo, "r"); // Private CPython API
113120
Py_DECREF(fo);
114121
#else
122+
// Let python open the file to avoid potential binary incompatibilities.
115123
PyObject *pyfile = PyFile_FromString(f, const_cast<char*>("r"));
116124
if (!pyfile) throw std::invalid_argument(std::string(f) + " : no such file");
117125
python::handle<> file(pyfile);

src/wrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace detail
2525

2626
if (
2727
PyMethod_Check(m.get())
28-
&& ((PyMethodObject*)m.get())->im_self == this->m_self
28+
&& PyMethod_GET_SELF(m.get()) == this->m_self
2929
&& class_object->tp_dict != 0
3030
)
3131
{
@@ -34,7 +34,7 @@ namespace detail
3434

3535

3636
}
37-
if (borrowed_f != ((PyMethodObject*)m.get())->im_func)
37+
if (borrowed_f != PyMethod_GET_FUNCTION(m.get()))
3838
return override(m);
3939
}
4040
}

0 commit comments

Comments
 (0)