--- Begin Message ---
Subject: |
26.0.90; wrong-type-argument in the Python Flymake backend |
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.
address@hidden | -- Fortunato Depero, 1929.
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#29174: 26.0.90; wrong-type-argument in the Python Flymake backend |
Date: |
Thu, 09 Nov 2017 21:29:58 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) |
Lele Gaifax <address@hidden> 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
--- End Message ---