darrenburns / dunk

Prettier git diffs in the terminal 🎨
745 stars 15 forks source link

Stack trace: RuntimeError: generator raised StopIteration #12

Open danielhoherd opened 2 years ago

danielhoherd commented 2 years ago
$ pipx install dunk
  installed package dunk 0.4.0a0, installed using Python 3.10.4
  These apps are now globally available
    - dunk
done! ✨ 🌟 ✨
$ git clone git@github.com:darrenburns/dunk.git
Cloning into 'dunk'...
remote: Enumerating objects: 129, done.
remote: Counting objects: 100% (129/129), done.
remote: Compressing objects: 100% (84/84), done.
remote: Total 129 (delta 52), reused 98 (delta 34), pack-reused 0
Receiving objects: 100% (129/129), 46.59 KiB | 11.65 MiB/s, done.
Resolving deltas: 100% (52/52), done.
$ cd dunk
$ git show 53acb8e | dunk

...lots of normal dunk content...

Traceback (most recent call last):
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/syntax.py", line 458, in tokens_to_spans
    _token_type, token = next(tokens)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/danielh/.local/bin/dunk", line 8, in <module>
    sys.exit(main())
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/dunk/dunk.py", line 352, in main
    source_syntax_lines: List[List[Segment]] = console.render_lines(
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/console.py", line 1334, in render_lines
    lines = list(
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/segment.py", line 291, in split_and_crop_lines
    for segment in segments:
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/console.py", line 1299, in render
    for render_output in iter_render:
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/syntax.py", line 554, in __rich_console__
    text = self.highlight(code, self.line_range)
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/syntax.py", line 470, in highlight
    text.append_tokens(tokens_to_spans())
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/text.py", line 969, in append_tokens
    for content, style in tokens:
RuntimeError: generator raised StopIteration

Tested on macOS 12.3.1 with python 3.9.12 and ubuntu 22.04 with python 3.10.4, both installed via pipx.

reduxionist commented 2 years ago

FWIW, I was unable to reproduce on Ubuntu 20.04 and Python 3.8.2, installed with pipx.

danielhoherd commented 2 years ago

This fails: $ docker run --rm -ti ubuntu:22.04 /bin/bash -exc 'apt update ; apt install -y git python3 python3-pip python3-venv ; pip install pipx ; pipx install dunk==0.4.0a0 ; git clone https://github.com/darrenburns/dunk.git ; cd dunk ; git show 53acb8e | "$HOME/.local/bin/dunk"'

It also fails when you use ubuntu:20.04