The memory leak only can be observed for some of the overloaded constructors of Py::String for Python3. The Python2 implementation of Py::String is not affected.
The affected constructors are:
https://sourceforge.net/p/cxx/code/HEAD/tree/trunk/CXX/CXX/Python3/Objects.hxx#l2069
https://sourceforge.net/p/cxx/code/HEAD/tree/trunk/CXX/CXX/Python3/Objects.hxx#l2075
https://sourceforge.net/p/cxx/code/HEAD/tree/trunk/CXX/CXX/Python3/Objects.hxx#l2081
https://sourceforge.net/p/cxx/code/HEAD/tree/trunk/CXX/CXX/Python3/Objects.hxx#l2087
What happens is that the Python functions PyUnicode_FromString and PyUnicode_FromStringAndSize return a new reference but when passing the PyObject pointer to Py::SeqBase the second argument "owned" is not set to true.
This causes the Py::Object constructor to re-increment the reference counter so that after creating a Py::String its value is 2.
Thus, the reference counter will never become 0 after a Py::String is being destroyed and the allocated memory won't be freed any more.
Thank you for the analysis and proposed fix. I just wanted to ack your work - I hope to work on this shortly.