(Bug#45679) and (Bug#46233) report buggy font-locking in python.el. I was able to trace it back to b2ce94fa5e - but I haven't been able to figure out _what_ the bug is (it's easy to trigger the issue, i.e. trigger the wonky font-locking), but not obvious how it's happening). Would it be reasonable to revert those changes (the attached patch does it)? I would also be happy to help solve the underlying issue (by testing new patches or being pointed to any tips for debugging font locking issues).