Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#49 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, rust

Hướng nghiên cứu

Bắt đầu bằng cách kiểm tra python/cel/exceptions.py, map_execution_error_to_python, cel.pyi và hướng dẫn thực hành về xử lý lỗi. Theo dõi các ánh xạ lỗi thực thi và lỗi phân tích cú pháp hiện có, sau đó xác minh rằng hệ thống phân cấp mới vẫn giữ nguyên việc xử lý các ngoại lệ tích hợp, hỗ trợ bắt cel.CelError và được ghi lại trong stub cũng như bảng của hướng dẫn thực hành.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
43
Fork
4
Merge trung bình
12 giờ 37 phút
Pull request đã merge (30 ngày)
11

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của hardbyte/python-common-expression-language

Tất cả issue của hardbyte/python-common-expression-language

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.