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