IngoMeyer441 / simple-term-menu

A Python package which creates simple interactive menus on the command line.
MIT License
491 stars 43 forks source link

Assertion error #78

Open svartkanin opened 1 year ago

svartkanin commented 1 year ago

Apologies in advance as I'm struggling to create a minimal example that reproduces this error, regardless I'll file a bug report as it may be clearer to the author what's going on.

...
  File "/home/dan/Git/archinstall/.venv/lib/python3.11/site-packages/simple_term_menu.py", line 1598, in show
    self._clear_menu()
  File "/home/dan/Git/archinstall/.venv/lib/python3.11/site-packages/simple_term_menu.py", line 1441, in _clear_menu
    assert self._previous_displayed_menu_height is not None
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

It seems that the assertion on line 1441 is failing as the _previous_displayed_menu_height variable is None. I did search the code for the usage and I could find only a single place where it's actually assigned which is on line 1435. The function this assignment happens in doesn't seem to be used anywhere though?

IngoMeyer441 commented 1 year ago

Could you please append a code example which produces this error message? Sorry, I didn't read your message carefully enough.

The error is a bit odd because the assignment is executed in the _paint_menu method, which must be called before the menu is cleared. This is the reason why an assertion is used in line 1441. The condition must always be true, otherwise the internal program logic has a bug.

IngoMeyer441 commented 1 year ago

Hmm, maybe another errors causes a skip of _paint_menu. _clear_menu is always called, because it is in a finally block (line 1598).