In Emacs version 24.5.3.
The error went away after applying the fix by Johan Claesson.
It seems that term.el has changed since this bug was first reported two years ago. Is there a reason that Johan's patch isn't accepted?
By the looking, this bug can bite term.el users at random time. It would be great to have it fixed in the mainline sooner.
Regards,
Jiangbin