KeyError on session_id
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 42/100
Direzione di ricerca
Start in libtmux/window.py, especially _list_panes and the _update_panes()._panes path, and reproduce the issue with a tmux command containing a newline in pane_start_command. Check how the resulting pane records are parsed and filtered; done means the reproduction no longer raises KeyError and records are not split into incorrect dictionaries.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I ran into the issue described in #36, and I've managed to track down the cause/a reproduction scenario. I initially posted this as a reply to that issue, but later noticed that it is preferred to create a new issue instead (according to the stale bot), so I've moved it here.
I started a new tmux server instance, and from the first window, I launched a new-window with a command with a newline in it: tmux new-window -t :2 -k $'echo foo\nread'. I then switched back to the first window, and ran the following in Python:
>>> import libtmux
>>> libtmux.__version__
'0.8.2'
>>> tmux = libtmux.Server()
>>> tmux.find_where({'session_name': '0'}).find_where({'window_name': 'python'}).attached_pane
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/maienm/.asdf/installs/python/utils/lib/python3.8/site-packages/libtmux/window.py", line 490, in attached_pane
for pane in self._panes:
File "/home/maienm/.asdf/installs/python/utils/lib/python3.8/site-packages/libtmux/window.py", line 514, in _panes
return self._list_panes()
File "/home/maienm/.asdf/installs/python/utils/lib/python3.8/site-packages/libtmux/window.py", line 506, in _list_panes
panes = [p for p in panes if p['session_id'] == self.get('session_id')]
File "/home/maienm/.asdf/installs/python/utils/lib/python3.8/site-packages/libtmux/window.py", line 506, in <listcomp>
panes = [p for p in panes if p['session_id'] == self.get('session_id')]
KeyError: 'session_id'
>>> tmux._update_panes()._panes
[{'session_name': '0', 'session_id': '$0', 'window_index': '1', 'window_id': '@0', 'window_name': 'python', 'history_size': '137', 'history_limit': '100000', 'history_bytes': '100636', 'pane_index': '1', 'pane_width': '240', 'pane_height': '66', 'pane_title': 'HOSTNAME', 'pane_id': '%0', 'pane_active': '1', 'pane_dead': '0', 'pane_in_mode': '0', 'pane_synchronized': '0', 'pane_tty': '/dev/pts/41', 'pane_pid': '337481', 'pane_current_path': '/home/maienm', 'pane_current_command': 'python', 'cursor_x': '0', 'cursor_y': '65', 'scroll_region_upper': '0', 'scroll_region_lower': '65', 'alternate_on': '0', 'alternate_saved_x': '0', 'alternate_saved_y': '0', 'cursor_flag': '1', 'insert_flag': '0', 'keypad_cursor_flag': '0', 'keypad_flag': '0', 'wrap_flag': '1', 'mouse_standard_flag': '0', 'mouse_button_flag': '0', 'mouse_any_flag': '0'}, {'session_name': '0', 'session_id': '$0', 'window_index': '2', 'window_id': '@2', 'window_name': 'zsh', 'history_size': '0', 'history_limit': '100000', 'history_bytes': '0', 'pane_index': '1', 'pane_width': '240', 'pane_height': '66', 'pane_title': 'HOSTNAME', 'pane_id': '%2', 'pane_active': '1', 'pane_dead': '0', 'pane_in_mode': '0', 'pane_synchronized': '0', 'pane_tty': '/dev/pts/42', 'pane_pid': '338918', 'pane_start_command': 'echo foo'}, {'session_name': 'read', 'window_index': '/home/maienm', 'window_id': 'zsh', 'window_name': '0', 'history_size': '1', 'history_limit': '0', 'history_bytes': '65', 'pane_height': '0', 'pane_title': '0', 'pane_id': '0', 'pane_active': '1', 'pane_dead': '0', 'pane_in_mode': '0', 'pane_synchronized': '0', 'pane_tty': '1', 'pane_pid': '0', 'pane_start_command': '0', 'pane_start_path': '0', 'pane_current_path': ''}]
It looks like the newline in pane_start_command causes the information for the second window to be broken into two dictionaries, each with part of the information.
I also tried this with a directory that contains a newline, which didn't result in an error, but did result in two panes with incorrect information (there was only one pane in this case):
[{'session_name': '0', 'session_id': '$0', 'window_index': '1', 'window_id': '@0', 'window_name': 'python', 'history_size': '3', 'history_limit': '100000', 'history_bytes': '2832', 'pane_index': '1', 'pane_width': '240', 'pane_height': '66', 'pane_title': 'HOSTNAME', 'pane_id': '%0', 'pane_active': '1', 'pane_dead': '0', 'pane_in_mode': '0', 'pane_synchronized': '0', 'pane_tty': '/dev/pts/41', 'pane_pid': '18834', 'pane_current_path': '/home/maienm/foo'}, {'session_name': 'bar', 'session_id': 'python', 'window_index': '0', 'window_id': '10', 'window_name': '0', 'history_size': '65', 'pane_index': '0', 'pane_width': '0', 'pane_height': '0', 'pane_title': '1', 'pane_id': '0', 'pane_active': '0', 'pane_dead': '0', 'pane_in_mode': '1', 'pane_synchronized': '0', 'pane_tty': '0', 'pane_pid': '0'}]
- Lingua principale
- Python
- Stelle
- 1.2k
- Fork
- 127
- Merge medio
- 2h 13m
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tmux-python/libtmux
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
tmux-python/libtmux#759 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
tmux-python/libtmux#745 · 2 commenti ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
tmux-python/libtmux#744 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
tmux-python/libtmux#731 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
tmux-python/libtmux#654 ·
Tutte le issue di tmux-python/libtmux
Issue simili
-
货币战争手改优先级配置缺少列表元素类型校验(P3) Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Apertaarea: ci bug perceived difficulty: 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ClickHouse/clickhouse-connect#1057 ·