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