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

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 09 Nov 2017 21:31:03 +0000

Your bug report

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

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
29174: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=29174
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#29174: 26.0.90; wrong-type-argument in the Python Flymake backend
From: [email-masked] (João Távora)
To: Lele Gaifax <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Thu, 09 Nov 2017 21:29:58 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Lele Gaifax <[email-masked]> writes:

>>>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",

Yes, that is probably the case, but in that discussion we decided it is
normal from time to time, especially if you quickly remove characters
from the buffer end after check has already started. So it is probably
the "same" case, not another case.

> 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... :-)

The problem is the (beg . end) = (flymake-diag-region...) clause in the
cl-loop. That call assumes that flymake-diag-region will always return a
cons, or nil, but it this case (the invalid region case), it was
returning t instead. That doesn't destructure nicely into (beg . end),
and so errors with a cryptic backtrace that confused you.

Fixed this in 89382780e1729861d98eca6e028ca1c62662a59f.

Thanks,
João

Subject: 26.0.90; wrong-type-argument in the Python Flymake backend
From: Lele Gaifax <[email-masked]>
To: [email-masked]
Date: Mon, 06 Nov 2017 20:22:03 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

>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.