Summary
pyqasm.loads("") raises AttributeError: 'NoneType' object has no attribute 'line' instead of a ValidationError. Whitespace-only input does the same. Every other unparseable string raises ValidationError("Failed to parse OpenQASM string: ..."), so a caller that catches PyQasmError to reject bad input lets this one through as a crash.
Repro (pyqasm 1.2.1, openqasm3 1.0.1, Python 3.12)
import pyqasm
pyqasm.loads("") # AttributeError: 'NoneType' object has no attribute 'line'
pyqasm.loads(" \n") # same
pyqasm.loads("this is not qasm") # ValidationError, as expected
Expected
ValidationError, like any other program the parser cannot read. loads("OPENQASM 3.0;\n") already returns an empty module, so the empty-string case is the only one that is neither a module nor a ValidationError.
Related: #388 covers bare expression statements reaching the same AttributeError; this one is the empty / whitespace-only input.
Summary
pyqasm.loads("")raisesAttributeError: 'NoneType' object has no attribute 'line'instead of aValidationError. Whitespace-only input does the same. Every other unparseable string raisesValidationError("Failed to parse OpenQASM string: ..."), so a caller that catchesPyQasmErrorto reject bad input lets this one through as a crash.Repro (pyqasm 1.2.1, openqasm3 1.0.1, Python 3.12)
Expected
ValidationError, like any other program the parser cannot read.loads("OPENQASM 3.0;\n")already returns an empty module, so the empty-string case is the only one that is neither a module nor aValidationError.Related: #388 covers bare expression statements reaching the same
AttributeError; this one is the empty / whitespace-only input.