Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Common base class for CEL exceptions, without breaking the existing builtin mappings

Offen
#49 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python, rust

Rechercherichtung

Beginne mit der Untersuchung von python/cel/exceptions.py, map_execution_error_to_python, cel.pyi und dem How-to zur Fehlerbehandlung. Verfolge die bestehenden Zuordnungen von Ausführungs- und Parse-Fehlern und überprüfe anschließend, dass die neue Hierarchie die Behandlung integrierter Ausnahmen beibehält, das Abfangen von cel.CelError unterstützt und in der Stub-Datei sowie in der How-to-Tabelle dokumentiert ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

enhancement

Follow-up promised when closing #23. Execution errors are mapped to the idiomatic builtin (RuntimeError, TypeError, KeyError, IndexError, ZeroDivisionError, OverflowError) and parse errors to ValueError, which is right for each case but means "did the rule run and fail" needs a five-clause except:

except (RuntimeError, TypeError, KeyError, IndexError, ArithmeticError):

Proposal

Add a cel.CelError hierarchy whose members also inherit from the builtin they replace, so nothing existing breaks:

class CelError(Exception): ...
class CelParseError(CelError, ValueError): ...
class CelRuntimeError(CelError, RuntimeError): ...
class CelTypeError(CelError, TypeError): ...
class CelKeyError(CelError, KeyError): ...
class CelIndexError(CelError, IndexError): ...
class CelZeroDivisionError(CelError, ZeroDivisionError): ...
class CelOverflowError(CelError, OverflowError): ...

except TypeError keeps working; except cel.CelError catches everything CEL raised; except cel.CelParseError separates a bad rule from a failed check.

Implementation notes

PyO3's create_exception! only takes a single base, so define the classes in a small python/cel/exceptions.py and have map_execution_error_to_python look them up from the module once (a GILOnceCell<Py<PyType>> per class) and raise with PyErr::from_type. Add them to cel.pyi and to the error-handling how-to, whose current table becomes the mapping between the two hierarchies.

Vorherrschende Sprache
Python
Sterne
43
Forks
4
Ø Merge
12 Std. 37 Min.
Gemergte PRs (30 T.)
11

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus hardbyte/python-common-expression-language

Alle Issues in hardbyte/python-common-expression-language

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.