While trying to use Py::Boolean for the first time when it appeared in PyCXX I got to such problems:
1) acceptance of 'True' or 'False' Python types only
2) bad ref. counting if was created from another Py::Object
While fixing the problem, I have also added some convenient change to Py::Int Py::Long Py::LongLong types to be accepting 'unsigned int' for constructor/operator=. It is useful for users who usually export object ids, 32bit guids and etc. that have to convert into 'int' explicitly (this is what is done in our project all over).
Here is the change log:
+++ Py::Boolean: fixed acceptance of 'True' or 'False' Python types only, and changed to native Python boolean types support using PyObject_IsTrue() check that returns (-1) on non-boolean type. Now PyCXX supports Python similar Mapping/Sequence types testing with Py::Boolean object. Numeric types are now also supported as supposed to be, e.g. 0(FALSE) 1(TRUE), -2(FALSE) -1(TRUE).
+++ Py::Boolean: fixed crash bug on bad pointer appearing in Py::Boolean after creation from another Py::Object or assigned from it. Now it does reference counting (e.g. it is not pretending as pointer owner) that resolves situation.
+++ added native support for 'unsinged int' type for Py::Int Py::Long Py::LongLong
+++ Py::Object: new method 'isBoolean()' to test object on Python explicit boolean type, e.g. 'True' or 'False'
Patch is for rev.101
Log in to post a comment.