Fix parent_file getter so that checks hasattr first