From 28e2c6512cf3878518dff82532650144e849198e Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Thu, 3 May 2018 14:10:20 +0000 Subject: [PATCH 1/5] Add Gitter badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e6f5d0d5..7646d3a8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ # Synopsis +[![Join the chat at https://gitter.im/boostorg/python](https://badges.gitter.im/boostorg/python.svg)](https://gitter.im/boostorg/python?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + Welcome to Boost.Python, a C++ library which enables seamless interoperability between C++ and the Python programming language. The library includes support for: * References and Pointers From 467a89eba794799e5e62a3945f78fd1e0eec506c Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Sun, 6 May 2018 13:35:16 -0400 Subject: [PATCH 2/5] Fix issue 198. --- src/object/class.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/object/class.cpp b/src/object/class.cpp index aeef688e..9bb9683a 100644 --- a/src/object/class.cpp +++ b/src/object/class.cpp @@ -618,7 +618,7 @@ namespace objects { object property( (python::detail::new_reference) - PyObject_CallFunction((PyObject*)&PyProperty_Type, const_cast("Osss"), fget.ptr(), 0, 0, docstr)); + PyObject_CallFunction((PyObject*)&PyProperty_Type, const_cast("Osss"), fget.ptr(), (char*)NULL, (char*)NULL, docstr)); this->setattr(name, property); } @@ -628,7 +628,7 @@ namespace objects { object property( (python::detail::new_reference) - PyObject_CallFunction((PyObject*)&PyProperty_Type, const_cast("OOss"), fget.ptr(), fset.ptr(), 0, docstr)); + PyObject_CallFunction((PyObject*)&PyProperty_Type, const_cast("OOss"), fget.ptr(), fset.ptr(), (char*)NULL, docstr)); this->setattr(name, property); } From b4230e98f665da643030e596c935a4e1bc14dba4 Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Mon, 4 Jun 2018 09:34:00 -0400 Subject: [PATCH 3/5] Fix auto-linking logic for boost_numpy (Windows only). --- include/boost/python/numpy/config.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/python/numpy/config.hpp b/include/boost/python/numpy/config.hpp index e6484bc5..f70b94cb 100644 --- a/include/boost/python/numpy/config.hpp +++ b/include/boost/python/numpy/config.hpp @@ -62,7 +62,9 @@ // Set the name of our library, this will get undef'ed by auto_link.hpp // once it's done with it: // -#define BOOST_LIB_NAME boost_numpy##PY_MAJOR_VERSION##PY_MINOR_VERSION +#define _BOOST_PYTHON_CONCAT(N, M, m) N ## M ## m +#define BOOST_PYTHON_CONCAT(N, M, m) _BOOST_PYTHON_CONCAT(N, M, m) +#define BOOST_LIB_NAME BOOST_PYTHON_CONCAT(boost_numpy, PY_MAJOR_VERSION, PY_MINOR_VERSION) // // If we're importing code from a dll, then tell auto_link.hpp about it: // @@ -75,6 +77,9 @@ #include #endif // auto-linking disabled +#undef BOOST_PYTHON_CONCAT +#undef _BOOST_PYTHON_CONCAT + #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #endif // CONFIG_NUMPY20170215_H_ From ac62db1cf17c0af44dc2b2117f9ddeee327e5e7c Mon Sep 17 00:00:00 2001 From: Markus Gerstel Date: Fri, 8 Jun 2018 18:08:05 +0100 Subject: [PATCH 4/5] Drop injector code example from tutorials. This example depends on the behaviour of ```__metaclass__```. This has changed in python 3, and the example no longer works. Removing example code as suggested, see #210 for more details and possible alternatives. Closes #210. --- doc/tutorial.qbk | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/doc/tutorial.qbk b/doc/tutorial.qbk index b3dcfc94..71d25850 100644 --- a/doc/tutorial.qbk +++ b/doc/tutorial.qbk @@ -1871,36 +1871,6 @@ This technique has several advantages: * Minimize the need to recompile * Rapid prototyping (you can move the code to C++ if required without changing the interface) -You can even add a little syntactic sugar with the use of metaclasses. Let's -create a special metaclass that "injects" methods in other classes. - - # The one Boost.Python uses for all wrapped classes. - # You can use here any class exported by Boost instead of "point" - BoostPythonMetaclass = point.__class__ - - class injector(object): - class __metaclass__(BoostPythonMetaclass): - def __init__(self, name, bases, dict): - for b in bases: - if type(b) not in (self, type): - for k,v in dict.items(): - setattr(b,k,v) - return type.__init__(self, name, bases, dict) - - # inject some methods in the point foo - class more_point(injector, point): - def __repr__(self): - return 'Point(x=%s, y=%s)' % (self.x, self.y) - def foo(self): - print 'foo!' - -Now let's see how it got: - - >>> print point() - Point(x=10, y=10) - >>> point().foo() - foo! - Another useful idea is to replace constructors with factory functions: _point = point From ed4776b59caec6dfbea548a96701a810653e6f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Wanzenb=C3=B6ck?= Date: Wed, 11 Jul 2018 11:57:46 +0200 Subject: [PATCH 5/5] Add missing return statement in numpy import This adds a missing return statement in the python3 specific import logic of boost.python.numpy. For python3 wrap_import_array() needs to return a pointer value. The import_array() macro only returns NULL in case of error. The missing return statement is UB, so the compiler can assume it does not happen. This means the compiler can assume the error branch is always taken, so import_array must always fail. --- src/numpy/numpy.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/numpy/numpy.cpp b/src/numpy/numpy.cpp index 8e259bc7..3ae2295e 100644 --- a/src/numpy/numpy.cpp +++ b/src/numpy/numpy.cpp @@ -19,6 +19,7 @@ static void wrap_import_array() static void * wrap_import_array() { import_array(); + return NULL; } #endif