> Why do you need that intermediate buffer to be in Python mode?
That's an intermediate state of the buffer where the rest of the migration code is. I was not trying to hit a corner case, this is just the way I happen to write code -- sometimes a paste text into the the buffer where the rest of the code is and then I edit it until it becomes a valid data structure. I am pretty sure I am not the only one who does this.
> I guess because the code is tuned to support valid Python code, not something that shouldn't happen in Python sources?
That example *is* a valid python code. And the behavior I see *is* a bug. And honestly, I don't think that this was a design choice along the lines "we're going to write an optimal parser for this subset of the language but we will occasionally hang up on this one".