compiler: py_document: handle empty documents correctly