Closed erlend-aasland closed 8 months ago
After the latest yak-shaving, the diff for this PR is now greatly reduced.
Victor had some remarks about this PR; I'll try to address them tomorrow:
lineno
but not filename
- it is unclear what happens if you pass
lineno
but notfilename
Come to think of it, that is also a concern with the current code; this PR does not alter the status quo.
I wrote a different approach: https://github.com/python/cpython/pull/114752
Maybe some of these changes are still relevent with my change, I didn't dig into the code yet.
Upstreamed as python/cpython#115510
Here's an experiment I thought of earlier today, as a step towards error handling without global state. One of the biggest pains wrt. getting rid of the
clinic
global is thatfail
depends on it too much. So here's the experiment:warn_or_fail
It is a crude change, but it kind of works, and I think it might be an improvement (if polished a little bit).
Side-effects:
IMO, we should just use a variety of custom exceptions, catch these during parsing, format the error message and reraise it (for either the CLI or the test suite to catch).