Qix- / better-exceptions

Pretty and useful exceptions in Python, automatically.
MIT License
4.59k stars 203 forks source link

weird escape chars instead of lines #114

Open gilbh opened 3 years ago

gilbh commented 3 years ago

two problems:

1) I just installed with pip and ran a test script for hook. Odd results. This is in Windows 10 command line:

(utils) C:\Dropbox\Documents_and_Writings\Research\Digital_Humanities\Python>pip install frosch
Collecting frosch
  Downloading frosch-0.1.7-py3-none-any.whl (14 kB)
Collecting asttokens<3.0.0,>=2.0.4
  Downloading asttokens-2.0.4-py2.py3-none-any.whl (20 kB)
Requirement already satisfied: six in c:\users\gil\envs\utils\lib\site-packages (from asttokens<3.0.0,>=2.0.4->frosch) (1.15.0)
Collecting colorama<0.5.0,>=0.4.4
  Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting Pygments<3.0.0,>=2.7.2
  Downloading Pygments-2.7.3-py3-none-any.whl (950 kB)
     |████████████████████████████████| 950 kB 2.2 MB/s
Collecting pytest-sugar<0.10.0,>=0.9.4
  Downloading pytest-sugar-0.9.4.tar.gz (12 kB)
Requirement already satisfied: termcolor>=1.1.0 in c:\users\gil\envs\utils\lib\site-packages (from pytest-sugar<0.10.0,>=0.9.4->frosch) (1.1.0)
Requirement already satisfied: packaging>=14.1 in c:\users\gil\envs\utils\lib\site-packages (from pytest-sugar<0.10.0,>=0.9.4->frosch) (20.4)
Requirement already satisfied: pyparsing>=2.0.2 in c:\users\gil\envs\utils\lib\site-packages (from packaging>=14.1->pytest-sugar<0.10.0,>=0.9.4->frosch) (2.4.7)
Collecting pytest>=2.9
  Downloading pytest-6.2.1-py3-none-any.whl (279 kB)
     |████████████████████████████████| 279 kB 3.2 MB/s
Requirement already satisfied: attrs>=19.2.0 in c:\users\gil\envs\utils\lib\site-packages (from pytest>=2.9->pytest-sugar<0.10.0,>=0.9.4->frosch) (19.3.0)
Requirement already satisfied: toml in c:\users\gil\envs\utils\lib\site-packages (from pytest>=2.9->pytest-sugar<0.10.0,>=0.9.4->frosch) (0.10.1)
Collecting atomicwrites>=1.0
  Downloading atomicwrites-1.4.0-py2.py3-none-any.whl (6.8 kB)
Collecting pluggy<1.0.0a1,>=0.12
  Downloading pluggy-0.13.1-py2.py3-none-any.whl (18 kB)
Collecting py>=1.8.2
  Downloading py-1.10.0-py2.py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 3.2 MB/s
Collecting stack-data<0.2.0,>=0.1.0
  Downloading stack_data-0.1.0-py3-none-any.whl (20 kB)
Collecting yapf<0.31.0,>=0.30.0
  Downloading yapf-0.30.0-py2.py3-none-any.whl (190 kB)
     |████████████████████████████████| 190 kB 3.3 MB/s
Collecting executing
  Downloading executing-0.5.4-py3-none-any.whl (12 kB)
Collecting iniconfig
  Downloading iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Collecting pure-eval
  Downloading pure_eval-0.1.1-py3-none-any.whl (9.4 kB)
Building wheels for collected packages: pytest-sugar
  Building wheel for pytest-sugar (setup.py) ... done
  Created wheel for pytest-sugar: filename=pytest_sugar-0.9.4-py2.py3-none-any.whl size=8977 sha256=450a8aee9c6f1418955904f4d15e157340f920f76b40aa093f652d3e3880ce9f
  Stored in directory: c:\users\gil\appdata\local\pip\cache\wheels\11\15\a5\18fe38a58318bf4aa4bc15c369d8dd7ec9210164812c48b8ba
Successfully built pytest-sugar
Installing collected packages: py, pluggy, iniconfig, colorama, atomicwrites, pytest, pure-eval, executing, asttokens, yapf, stack-data, pytest-sugar, Pygments, frosch
  Attempting uninstall: colorama
    Found existing installation: colorama 0.4.3
    Uninstalling colorama-0.4.3:
      Successfully uninstalled colorama-0.4.3
  Attempting uninstall: Pygments
    Found existing installation: Pygments 2.6.1
    Uninstalling Pygments-2.6.1:
      Successfully uninstalled Pygments-2.6.1
Successfully installed Pygments-2.7.3 asttokens-2.0.4 atomicwrites-1.4.0 colorama-0.4.4 executing-0.5.4 frosch-0.1.7 iniconfig-1.1.1 pluggy-0.13.1 pure-eval-0.1.1 py-1.10.0 pytest-6.2.1 pytest-sugar-0.9.4 stack-data-0.1.0 yapf-0.30.0

(utils) C:\Dropbox\Documents_and_Writings\Research\Digital_Humanities\Python>p test_frosch.py
Traceback (most recent call last):
  File "C:\Dropbox\Documents_and_Writings\Research\Digital_Humanities\Python\test_frosch.py", line 4, in <module>
    x = 3 + 'asdf'
TypeError: unsupported operand type(s) for +: 'int' and 'str'

 4 || x = 3 + 'asdf'
   || │
   || └── x = None
   ||

Here's the code of test_frosch.py:

from frosch import hook

# hook(theme='vim')
hook()
x = 3 + 'asdf'

When I try to run with IPython inside nvim Terminal -- nothing happens at all (as if the hook() does not, well, hook):

(utils) C:\Dropbox\Documents_and_Writings\Research\Digital_Humanities\Python
>ipython --pprint
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit
Type 'copyright', 'credits' or 'license' for more information
IPython 7.18.1 -- An enhanced Interactive Python. Type '?' for help.

In [4]: %run "C:\Dropbox\Documents_and_Writings\Research\Digital_Humanities
   ...: \Python\test_frosch.py"
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
C:\Dropbox\Documents_and_Writings\Research\Digital_Humanities\Python\test_frosch
.py in <module>
      3 # hook(theme='vim')
      4 hook()
----> 5 x = 3 + 'asdf'

TypeError: unsupported operand type(s) for +: 'int' and 'str'

In [5]:

Thanks!

Qix- commented 3 years ago

Windows 10 command line

Which terminal emulator? cmd.exe, Windows Terminal, powershell, etc.

inside nvim Terminal

Can you expand on this? Which environment are you running? By nvim do you mean neovim?

gilbh commented 3 years ago

This happens on my two computers, both run Windows 10, through the cmd.exe. Yes, nvim is neovim, but that is not what causes the issue. The screen shot shows both failures from the cmd.exe, the first with python and the second with ipython: image

I am running Python 3.8.6 inside a virtualenv.

gilbh commented 3 years ago

You can see in the above screen shot: 1) for python, the characters come out wrong. 2) for ipython, there is no hook.

Qix- commented 3 years ago

cmd.exe doesn't support ansi escape characters. Switch to Microsoft Terminal (from the app store). Not only is it faster but it's the all around better option. It's the new official terminal by Microsoft. It'll support all of the ansi escapes.

gilbh commented 3 years ago

Yup, Terminal did it. Is there any solution for ipython integration?

Gil Ben-Herut, PhD Associate Professor Director of Graduate Studies Department of Religious Studies University of South Florida http://religious-studies.usf.edu/faculty/gbherut/

Check out my recent monograph Śiva's Saints: The Origins of Devotion in Kannada according to Harihara's Ragaḷegaḷu https://global.oup.com/academic/product/sivas-saints-9780190878849?cc=us&lang=en&and the co-edited volume Regional Communities of Devotion in South Asia: Insiders, Outsiders, and Interlopers https://www.crcpress.com/Regional-Communities-of-Devotion-in-South-Asia-Insiders-Outsiders-and/Ben-Herut-Keune-Monius/p/book/9781138495838

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Dec 29, 2020 at 8:03 AM Qix notifications@github.com wrote:

cmd.exe doesn't support ansi escape characters. Switch to Microsoft Terminal (from the app store). Not only is it faster but it's the all around better option.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Qix-/better-exceptions/issues/114#issuecomment-752067514, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJNTQQQPILE4Q32YUBHXHKDSXHHRVANCNFSM4VMO7MTA .