elpy icon indicating copy to clipboard operation
elpy copied to clipboard

Non printable shell characters in the Python traceback

Open arael opened this issue 3 years ago • 1 comments

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.

[0;31m---------------------------------------------------------------------------[0m
[0;31mSystemExit[0m                                Traceback (most recent call last)
[0;32m/usr/lib/python3.8/runpy.py[0m in [0;36mrun_module[0;34m(mod_name, init_globals, run_name, alter_sys)[0m
[1;32m    205[0m         [0mrun_name[0m [0;34m=[0m [0mmod_name[0m[0;34m[0m[0;34m[0m[0m
[1;32m    206[0m     [0;32mif[0m [0malter_sys[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[0;32m--> 207[0;31m         [0;32mreturn[0m [0m_run_module_code[0m[0;34m([0m[0mcode[0m[0;34m,[0m [0minit_globals[0m[0;34m,[0m [0mrun_name[0m[0;34m,[0m [0mmod_spec[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m    208[0m     [0;32melse[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[1;32m    209[0m         [0;31m# Leave the sys module alone[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m

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

arael avatar Jan 22 '22 04:01 arael

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

gopar avatar Nov 14 '22 00:11 gopar