jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 262 forks source link

Non printable shell characters in the Python traceback #1959

Open arael opened 2 years ago

arael commented 2 years ago

Summary

I have a problem with the elpy output when I run the tests.

A lot of non printable shell characters are shown in the traceback and make the output unreadable.

Here is the part of the output, it is much longer than this. The non printable characters make it difficult to understand what is going on in the Python traceback log.

---------------------------------------------------------------------------
SystemExit                                Traceback (most recent call last)
/usr/lib/python3.8/runpy.py in run_module(mod_name, init_globals, run_name, alter_sys)
    205         run_name = mod_name
    206     if alter_sys:
--> 207         return _run_module_code(code, init_globals, run_name, mod_spec)
    208     else:
    209         # Leave the sys module alone

Steps to reproduce

Just run a test and make it fail. Press C-c C-t and scroll. The non printable characters should be there.

My configuration

OS

Ubuntu 20.04.3 LTS

Result of (elpy-config)

# Paste it here
Emacs.............: 27.1
Elpy..............: 1.35.0
Virtualenv........: None
Interactive Python: ipython3 7.13.0 (/usr/bin/ipython3)
RPC virtualenv....: rpc-venv (/home/arael/.emacs.d/elpy/rpc-venv)
 Python...........: python 3.8.10 (/home/arael/.emacs.d/elpy/rpc-venv/bin/python)
 Jedi.............: 0.18.1
 Autopep8.........: 1.6.0
 Yapf.............: 0.32.0
 Black............: 21.12b0
Syntax checker....: Not found (flake8)

Elpy configuration in my init.el

# Paste it here

  (use-package elpy
    :ensure t
    :init
    :config
    (setq elpy-shell-starting-directory #'current-directory)
    (setq elpy-shell-echo-output nil)
    (elpy-enable))
gopar commented 2 years ago

Does this help?

(use-package ansi-color
  :ensure nil
  :defer t
  :hook (compilation-filter . gopar/colorize-compilation-buffer)
  :init
  ;; https://stackoverflow.com/questions/3072648/cucumbers-ansi-colors-messing-up-emacs-compilation-buffer
  (defun gopar/colorize-compilation-buffer ()
    "Colorize the output from compile buffer"
    (toggle-read-only)
    (ansi-color-apply-on-region (point-min) (point-max))
    (toggle-read-only)))