fix corner cases from Python3 parser that causes NPE