Translated commit 45eae1c to Python