python: fix crash when loading scripts with Python 3.x (patch #8044) (thanks to isak)