Python: cherry-picked changes from lts.