Fix a Python3 compatibility issue

Thanks to splith for reporting the bug.