hy
hy copied to clipboard
More misplaced tracebacks
There are cases not fixed by #2423 in which position information is still set incorrectly:
$ echo ';;;;;;\n(do-mac (quote (raise (ValueError))))' >ex.hy
$ hy ex.hy
Traceback (most recent call last):
…
File "/tmp/ex.hy", line 1, in <module>
;;;;;;
ValueError
$ echo ';;;;;\n(defmacro m [] (quote (do (raise (ValueError)))))\n(m)' >ex.hy
$ hy ex.hy
Traceback (most recent call last):
…
File "/tmp/ex.hy", line 1, in <module>
;;;;;
ValueError
(Note that the do
is necessary to reproduce the bug in the second case.)
These don't look so easy to fix. I think #1951 may have been ill-advised: producing bogus default positions for models without positions leads to bugs that are harder to track down than crashes that occur immediately upon constructing the AST. But ultimately there may be no reasonable positions to assign to some dynamically generated models, in which case Python still needs something. I'm not sure.
I've opened https://github.com/pytest-dev/pytest/pull/10840 to prevent pytest from crashing on this and any other cases. (Edit: This was merged, and indeed pytest no longer seems to have those crashes.)