1

I'm running a hand-built recent trunk build of emacs on Windows. I have flycheck set up, and flycheck-verify-setup in a python-mode buffer shows it's enabled and OK:

Syntax checkers for buffer foo.py in python-mode:

  python-flake8 (disabled)
    - may enable:         Automatically disabled!
    - executable:         Not found
    - configuration file: Not found

  python-pylint (disabled)
    - may enable:         Automatically disabled!
    - executable:         Not found
    - configuration file: Not found

  python-pycompile
    - may enable: yes
    - executable: Found at c:/Program Files/Python36/python.exe

Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled checkers.

--------------------

Flycheck version: 32snapshot (package: 20171214.1215)
Emacs version:    26.0.50
System:           x86_64-w64-mingw32
Window system:    w32

But whenever I create a syntax error in my .py file, I get this error from flycheck:

Suspicious state from syntax checker python-pycompile: 
Flycheck checker python-pycompile returned non-zero exit code 1, 
but its output contained no errors:   File ".../foo.py", line 4
    import sys,os
         ^
SyntaxError: invalid syntax

And running M-x flycheck-compile with python-pycompile shows it's compiling it fine, and getting the above error as it should, and returning exit status 1. So why does flycheck think there are "no errors" in that output? Is there a regex somewhere I need to adjust so it treats those lines as error or something?

2
  • OK, I see why it's doing that. On Windows, the error messages have Windows line-endings (\r\n). The python-pycompile flycheck checker error pattern doesn't account for that. Is there any kind of error preprocessing that would strip CRs? Especially a generic one that would work for all checkers?
    – GaryO
    Mar 5, 2018 at 15:57
  • Would rather check this other answer: stackoverflow.com/questions/37720869/…
    – mhass
    Apr 30, 2022 at 14:44

1 Answer 1

1

Here's a fix, for other Windows users with this problem. Replace the standard version of flycheck-parse-output with this one:

;;; On Windows, commands run by flycheck may have CRs (\r\n line endings).
;;; Strip them out before parsing.
(defun flycheck-parse-output (output checker buffer)
  "Parse OUTPUT from CHECKER in BUFFER.

OUTPUT is a string with the output from the checker symbol
CHECKER.  BUFFER is the buffer which was checked.

Return the errors parsed with the error patterns of CHECKER."
  (let ((sanitized-output (replace-regexp-in-string "\r" "" output))
        )
    (funcall (flycheck-checker-get checker 'error-parser) sanitized-output checker buffer)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.