BUG: fix issue #4678 for Python parser