Specific exceptions raising if pane or window manually closed
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
The traceback points to libtmux/pane.py (_info and send_keys) and libtmux/window.py (_info and kill_window); start there and reproduce each operation after its pane or window is manually closed. Done means these cases raise specific exceptions instead of IndexError.
Written by the indexing model from the issue text.
Description
Specific exceptions should be raised in some cases.
For example, if we send keys to a previously attached pane of a window, but the window is manually closed while the program is running, this hapens:
Traceback (most recent call last)
[...]
File "/usr/share//class_tmuxserver.py", line 78, in create_or_clear_window
self.dict_panes[window_name]["pane_cmd"].send_keys('C-c', enter=False, suppress_history=False)
File "/usr/share//venv/lib/python3.8/site-packages/libtmux/pane.py", line 117, in send_keys
self.cmd('send-keys', prefix + cmd)
File "/usr/share//venv/lib/python3.8/site-packages/libtmux/pane.py", line 90, in cmd
args = ('-t', self.get('pane_id')) + args
File "/usr/local/lib/python3.8/_collections_abc.py", line 660, in get
return self[key]
File "/usr/share//venv/lib/python3.8/site-packages/libtmux/common.py", line 251, in __getitem__
return self._info[key]
File "/usr/share//venv/lib/python3.8/site-packages/libtmux/pane.py", line 75, in _info
return list(filter(by, self.server._panes))[0]
`IndexError: list index out of range`
Same thing if we try to kill a window which was manually closed in the tmux:
Traceback (most recent call last)
[...]
File "/home/admin//src/class_tmuxserver.py", line 116, in kill_tmux_window
self.dict_windows[window_name].kill_window()
File "/home/admin//venv/lib64/python3.7/site-packages/libtmux/window.py", line 308, in kill_window
'-t%s:%s' % (self.get('session_id'), self.index),
File "/usr/lib64/python3.7/_collections_abc.py", line 660, in get
return self[key]
File "/home/admin//venv/lib64/python3.7/site-packages/libtmux/common.py", line 252, in __getitem__
return self._info[key]
File "/home/admin//venv/lib64/python3.7/site-packages/libtmux/window.py", line 89, in _info
return ret[0]
IndexError: list index out of range
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 127
- Avg merge
- 2h 13m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tmux-python/libtmux
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
tmux-python/libtmux#759 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tmux-python/libtmux#745 · 2 comments ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
tmux-python/libtmux#744 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tmux-python/libtmux#731 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tmux-python/libtmux#654 ·
All issues in tmux-python/libtmux
Similar issues
-
sponsored
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Diaoul/subliminal#1382 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
triage/confirmed
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
agentscope-ai/agentscope#2775 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100