[python] fix null pointer dereference when invoking non-addon scripts
Merge pull request #5425 from tamland/autoexec-fix

[python] fix null pointer dereference when invoking non-addon scripts