`show_option` coerces user options, so an `@` option set to `123` or `on` comes back as an int or a bool
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
Direzione di ricerca
Inizia in src/libtmux/options.py, con convert_values intorno alla riga 245 e _show_option intorno alla riga 1216, poi leggi la copertura esistente di test_custom_options. Verifica il comportamento delle opzioni @ usando i valori segnalati, confermando al contempo che le opzioni integrate come exit-unattached e history-limit continuino a essere sottoposte a conversione. Il lavoro è completato quando le stringhe delle opzioni utente tornano indietro senza modifiche e i test pertinenti hanno esito positivo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Filed against tmux-python/libtmux v0.62.0, tmux 3.6a.
What happens
convert_value applies tmux's built-in option coercion to every value, and the call sites reach user options too:
src/libtmux/options.py#L245 — convert_values, dict branch
src/libtmux/options.py#L1216 — _show_option, direct lookup
tmux(1) defines a user option as carrying an arbitrary string:
tmux also supports user options which are prefixed with a '@'. User options may have any name, so long as they are prefixed with '@', and be set to any string.
So a user option does not survive the round trip when its value happens to read as a tmux boolean or a number:
| set | show_option returns |
type |
|---|---|---|
123 |
123 |
int |
on |
True |
bool |
off |
False |
bool |
true |
'true' |
str |
3.5 |
'3.5' |
str |
show_options() returns the same converted values.
The coercion is right for built-in options — tmux really does use on/off there. For a @ name it is also not self-consistent: on converts but true does not, 123 converts but 3.5 does not.
Repro
import libtmux
server = libtmux.Server(socket_name="probe")
pane = server.new_session("probe").windows[0].panes[0]
for raw in ("123", "on", "off", "true", "3.5"):
pane.cmd("set-option", "-p", "@probe", raw)
got = pane.show_option("@probe")
print(f"{raw!r:8} -> {got!r:8} {type(got).__name__}")
'123' -> 123 int
'on' -> True bool
'off' -> False bool
'true' -> 'true' str
'3.5' -> '3.5' str
Why it bites
A @ option is the natural place to stamp an identity on a pane. When that identity is user-supplied, someone who names a thing 123, on or off gets back a value that no longer compares equal to what they set, so the pane cannot be found again.
Found while fixing awslabs/cli-agent-orchestrator, where it made a terminal named 123 unaddressable.
Note
The module docstring already treats these as their own category:
There are also custom user options, preceded with @, which exist are stored to
Options.context.user_optionsas a dictionary.
Options.context.user_options does not appear anywhere else in the source, so that looks like an intent that was never implemented.
I have a patch that guards both call sites on the @ prefix and adds the round-trip case to test_custom_options. Built-in options keep converting (exit-unattached → False, history-limit → 2000). Happy to open it as a PR if you want it shaped that way — it changes behaviour for anyone relying on the current conversion, so it seemed like your call rather than mine.
- Lingua principale
- Python
- Stelle
- 1.2k
- Fork
- 127
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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 68/100
tmux-python/libtmux#745 · 2 commenti ·
-
Documentation: how to use internal libtmux loggingForse già presa @tony l’ha presa 42 giorni fa. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
tmux-python/libtmux#744 ·
-
`test_control_mode_stdout_preserves_non_ascii_output` polls `select` on a buffered streamForse già presa @tony l’ha presa 65 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
tmux-python/libtmux#731 ·
-
Flaky test: test_capture_pane_flags[join_wrapped_numbers] matches marker in command echoForse già presa @tony l’ha presa 185 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
tmux-python/libtmux#654 ·
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
tmux-python/libtmux#740 · 1 commento ·
Tutte le issue di tmux-python/libtmux
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
FuRongJun-1999/dsh-memory#56 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
pgadmin-org/pgadmin4#10503 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
521xueweihan/HelloGitHub#3857 ·
-
needs-ac
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Ikalus1988/MisakaNet#2845 ·
I maintainer di solito rispondono entro 1 giorno
-
bug connectors operations
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pyinfra-dev/pyinfra#1989 ·
I maintainer di solito rispondono entro 3 giorni