Subject: bug#29174: 26.0.90; wrong-type-argument in the Python Flymake backend

From: Lele Gaifax <[email-masked]>
Date: Mon, 06 Nov 2017 20:22:03 +0100

>From time to time, while editing a python-mode with flymake-mode enabled, I
somehow trigger an error in the backend.

Unfortunately I'm not able to reproduce the problem in a deterministic way: it
really seems a timing issue, that is I was able to get it quickly
adding/removing random characters, but not too fast so to give Flymake the
opportunity to run the checker subprocess.

My guess is that it is another case of "the checker tool reported a line/col
position that does not exist anymore in the buffer", but the traceback below
does not seem to support my supposition, where in particular I fail to
understand from where the `t' that eventually is given to `cdr' may come from:
of course it may very well be due to my extremely low elisp-fu tricking
me... :-)

Here is a traceback (obtained after re-evaluating the
`python--flymake-parse-output' function source):

Debugger entered--Lisp error: (wrong-type-argument listp t)
  cdr(t)
  (setq end (cdr end))
  (prog1 end (setq end (cdr end)))
  (car-safe (prog1 end (setq end (cdr end))))
  (setq end (flymake-diag-region source (string-to-number (match-string lineidx)) (and colidx (match-string colidx) (string-to-number (match-string colidx)))) beg (car-safe (prog1 end (setq end (cdr end)))))
  (while (search-forward-regexp rx nil t) (setq msg (match-string msgidx)) (setq end (flymake-diag-region source (string-to-number (match-string lineidx)) (and colidx (match-string colidx) (string-to-number (match-string colidx)))) beg (car-safe (prog1 end (setq end (cdr end))))) (setq type (or (and typeidx (match-string typeidx) (assoc-default (match-string typeidx) python-flymake-msg-alist (function string-match))) (assoc-default msg python-flymake-msg-alist (function string-match)) :error)) (setq diags (nconc diags (list (flymake-make-diagnostic source beg end type msg)))))
  (let* ((msg nil) (end nil) (beg nil) (type nil) (diags nil)) (while (search-forward-regexp rx nil t) (setq msg (match-string msgidx)) (setq end (flymake-diag-region source (string-to-number (match-string lineidx)) (and colidx (match-string colidx) (string-to-number (match-string colidx)))) beg (car-safe (prog1 end (setq end (cdr end))))) (setq type (or (and typeidx (match-string typeidx) (assoc-default (match-string typeidx) python-flymake-msg-alist (function string-match))) (assoc-default msg python-flymake-msg-alist (function string-match)) :error)) (setq diags (nconc diags (list (flymake-make-diagnostic source beg end type msg))))) (funcall report-fn diags) nil)
  (save-current-buffer (set-buffer (process-buffer proc)) (goto-char (point-min)) (let* ((msg nil) (end nil) (beg nil) (type nil) (diags nil)) (while (search-forward-regexp rx nil t) (setq msg (match-string msgidx)) (setq end (flymake-diag-region source (string-to-number (match-string lineidx)) (and colidx (match-string colidx) (string-to-number (match-string colidx)))) beg (car-safe (prog1 end (setq end (cdr end))))) (setq type (or (and typeidx (match-string typeidx) (assoc-default (match-string typeidx) python-flymake-msg-alist (function string-match))) (assoc-default msg python-flymake-msg-alist (function string-match)) :error)) (setq diags (nconc diags (list (flymake-make-diagnostic source beg end type msg))))) (funcall report-fn diags) nil))
  (let ((rx (nth 0 python-flymake-command-output-pattern)) (lineidx (nth 1 python-flymake-command-output-pattern)) (colidx (nth 2 python-flymake-command-output-pattern)) (typeidx (nth 3 python-flymake-command-output-pattern)) (msgidx (nth 4 python-flymake-command-output-pattern))) (save-current-buffer (set-buffer (process-buffer proc)) (goto-char (point-min)) (let* ((msg nil) (end nil) (beg nil) (type nil) (diags nil)) (while (search-forward-regexp rx nil t) (setq msg (match-string msgidx)) (setq end (flymake-diag-region source (string-to-number (match-string lineidx)) (and colidx (match-string colidx) (string-to-number (match-string colidx)))) beg (car-safe (prog1 end (setq end (cdr end))))) (setq type (or (and typeidx (match-string typeidx) (assoc-default (match-string typeidx) python-flymake-msg-alist (function string-match))) (assoc-default msg python-flymake-msg-alist (function string-match)) :error)) (setq diags (nconc diags (list (flymake-make-diagnostic source beg end type msg))))) (funcall report-fn diags) nil)))
  python--flymake-parse-output(#<buffer tables/user_logins.py> #<process python-flymake> #f(compiled-function (&rest args) #<bytecode 0x1da5a89>))
  (progn (python--flymake-parse-output source proc report-fn))
  (if (save-current-buffer (set-buffer source) (eq proc python--flymake-proc)) (progn (python--flymake-parse-output source proc report-fn)))
  (unwind-protect (if (save-current-buffer (set-buffer source) (eq proc python--flymake-proc)) (progn (python--flymake-parse-output source proc report-fn))) (kill-buffer (process-buffer proc)))
  (progn (unwind-protect (if (save-current-buffer (set-buffer source) (eq proc python--flymake-proc)) (progn (python--flymake-parse-output source proc report-fn))) (kill-buffer (process-buffer proc))))
  (if (eq 'exit (process-status proc)) (progn (unwind-protect (if (save-current-buffer (set-buffer source) (eq proc python--flymake-proc)) (progn (python--flymake-parse-output source proc report-fn))) (kill-buffer (process-buffer proc)))))
  (closure ((source . #<buffer tables/user_logins.py>) (_args) (report-fn . #f(compiled-function (&rest args) #<bytecode 0x1da5a89>)) outline-heading-end-regexp python-shell--interpreter python-shell--interpreter-args ffap-alist comint-last-prompt-overlay t) (proc _event) (if (eq 'exit (process-status proc)) (progn (unwind-protect (if (save-current-buffer (set-buffer source) (eq proc python--flymake-proc)) (progn (python--flymake-parse-output source proc report-fn))) (kill-buffer (process-buffer proc))))))(#<process python-flymake> "exited abnormally with code 1\n")

Thanks a lot,
ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
[email-masked]  |                 -- Fortunato Depero, 1929.