Here is a reproducible recipe.

https://gist.github.com/stakemori/ccf0e4cfae2fcfafbf0a

I thought this is a bug of emacs-jedi (https://github.com/tkf/emacs-jedi/issues/234).
But I can reproduce it with "emacs -Q". (I use Emacs 24.5).

If I replace (buffer-string) in the body of my/add-to-after-change-functions
by (buffer-substring-no-properties (point-min) (point-max)),
then the same error occurs.

I think this has nothing to do with python-mode. It also occurs in text-mode.

Sincerely,
Sho Takemori