Python: several fixes (2) (cherry picked from commit aabadda0c2)
aabadda0c2
Python: several fixes (cherry picked from commit 67651d80bc)
67651d80bc