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

Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lost

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

Maintainer thường phản hồi trong vòng 1 ngày

@tonycoder-hub đang làm issue này rồi.

Từ ngày 12/10/2026.

  • #452 của @tonycoder-hub — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
22/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
developer-experience

Hướng nghiên cứu

The empty message comes from the ValidationError raised when pyqasm.loads() catches a parse failure; openqasm3/parser.py:107 re-raises QASM3ParsingError with no text, and the ANTLR diagnostic only reaches stderr. Read how the error listener is attached before changing anything. Linked PR #452 is already open against this, so check its status first. Done means str(exc) includes the line, column and ANTLR message.

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

Mô tả

bug
Summary

When pyqasm.loads() fails to parse, the ValidationError message is "Failed to parse OpenQASM string: " with nothing after the colon. The ANTLR diagnostic that says what is wrong (line 3:10 no viable alternative at input 'rx(pi/2q') goes to stderr only, so a service that surfaces str(exc) to a user gives them an empty reason.

Repro (pyqasm 1.2.1, openqasm3 1.0.1)
import pyqasm
try:
    pyqasm.loads("OPENQASM 3.0;\nqubit q;\nrx(pi / 2 q;\n")
except Exception as exc:
    print(repr(str(exc)))
# prints: 'Failed to parse OpenQASM string: '
# stderr: line 3:10 no viable alternative at input 'rx(pi/2q'

openqasm3.parser.QASM3ParsingError is raised with no message (raise QASM3ParsingError() from exc in openqasm3/parser.py:107), so {err} formats as empty.

Suggestion

Capture the ANTLR error listener output (line, column, message) and put it in the ValidationError message, e.g. Failed to parse OpenQASM string: line 3:10 no viable alternative at input 'rx(pi/2q'. Line and column would also let callers point at the offending statement.

Ngôn ngữ chính
Python
Star
29
Fork
33
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
15

Chuẩn bị môi trường

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 qBraid/pyqasm

Tất cả issue của qBraid/pyqasm

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.