unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29174: 26.0.90; wrong-type-argument in the Python Flymake backend
@ 2017-11-06 19:22 Lele Gaifax
  2017-11-09 21:29 ` João Távora
  0 siblings, 1 reply; 2+ messages in thread
From: Lele Gaifax @ 2017-11-06 19:22 UTC (permalink / raw)
  To: 29174

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.
lele@metapensiero.it  |                 -- Fortunato Depero, 1929.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#29174: 26.0.90; wrong-type-argument in the Python Flymake backend
  2017-11-06 19:22 bug#29174: 26.0.90; wrong-type-argument in the Python Flymake backend Lele Gaifax
@ 2017-11-09 21:29 ` João Távora
  0 siblings, 0 replies; 2+ messages in thread
From: João Távora @ 2017-11-09 21:29 UTC (permalink / raw)
  To: Lele Gaifax; +Cc: 29174, 29174-done

Lele Gaifax <lele@metapensiero.it> 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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-09 21:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06 19:22 bug#29174: 26.0.90; wrong-type-argument in the Python Flymake backend Lele Gaifax
2017-11-09 21:29 ` João Távora

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).