python 3 compliance
[#2032] possible memory leak fix