Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

QueryList exception do not inherit from libtmux.exc.LibTmuxException

Aperta
#541 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
api

Direzione di ricerca

Start with libtmux._internal.query_list.py and libtmux.exc to compare ObjectDoesNotExist with LibTmuxException, then inspect the top-level init.py and the documented exceptions reference. Done means the query exception hierarchy and public exposure match the supported API, with the intended behavior for sessions.get established.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I was porting today a legacy piece of software (written by another co-worker, I only maintain it) that was using libtmux-0.8.5 und made an upgrade to libtmux-0.24.0 and I was getting a lot of deprecation errors because of session.find_where usage.

The code looked mostly like this:

try:
    session = libtmux.Server().find_where({"session_name":session_name})
except libtmux.exc.LibTmuxException:
    session = libtmux.Server().new_session(session_name=session_name)

and I changed it to

tmux_server = libtmux.server.Server()
try:
    session = tmux_server.sessions.get(session_name=session_name)
except libtmux.exc.LibTmuxException:
    session = tmux_server.new_session(session_name=session_name)

I realized that when sessions.get does not found a session, it raises ObjectDoesNotExist. But ObjectDoesNotExist is declared like this:

class ObjectDoesNotExist(Exception):
    """The requested object does not exist."""

The problem is that ObjectDoesNotExist is actually defined in libtmux._internal.query_list.py while the the documentation says here https://libtmux.git-pull.com/reference/exceptions.html

exception libtmux.exc.LibTmuxException
    Base Exception for libtmux Errors.

I don't want to start importing stuff from submodules with a leading underscore as this is mostly used by "private" modules and cannot be considered part of the public API.

I think you should either expose those exception directly in the top __init__.py and at least make ObjectDoesNotExist and ObjectDoesNotExist both inherit from libtmux.exc.LibTmuxException to keep it consistent.

Is there a reason why the the query_list implementation is the ._internal private submodule and why those exceptions do not inherit from libtmux.exc.LibTmuxException?

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tmux-python/libtmux

Tutte le issue di tmux-python/libtmux

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.