Two patches are included. One fixes the fact that for some reason syntax-propertize--done has ceased to be buffer-local after commit [1] and for some reason commit [2] did not help. I did it the way other buffer-local variables are initialized and it worked. The change fixes #21657 that was failing because syntax-propertize--done was inherited from scratch buffer and docstring boundaries were not propertized as a result. The other infinite loop I found accidentally when adding a whitespace before module docstring. I have fixed one corner-case of it, but in other circumstances I'd argue that whatever smart extensions python-mode adds to forward-sexp, those extensions should never move point less than the normal forward-sexp should. Cheers, immerrr 1. https://github.com/emacs-mirror/emacs/commit/3928ef2dd5b8febf3b1d9c1bfb22af3698d16bea 2. https://github.com/emacs-mirror/emacs/commit/0360b7f2c4f0358106e229de4dfe91a67445a50c