pythonui: add NULL-checks