Uh oh!
There was an error while loading. Please reload this page.
gh-104683: Rework Argument Clinic error handling - #107551
Conversation
- Introduce ClinicError and ClinicWarning - fail() raises ClinicError - warn() uses warnings.warn(msg, ClinicWarning) - the CLI runs main(), catches ClinicError, formats the error message prints to stderr and exits with an error - adapt the test suite to work with ClinicError
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
erlend-aasland
commented
Aug 2, 2023
Ready for a new round of review! Finally, all (or most) line number are now correct. If I introduce an error in Lib/test/clinic.test.c, I now get an accurate line number. Yay! I'm not sure why some of the tests are off by one, though. Perhaps it has to do with FakeClinic. |
| try: | ||
| self.state(line) | ||
| except ClinicError as exc: | ||
| raise ClinicError(str(exc), filename=exc.filename, lineno=line_number) |
There was a problem hiding this comment.
IMO, this is a workaround! We should ensure that line numbers are correctly updated in the state machine. Let's create an issue about this.
There was a problem hiding this comment.
I'd like to keep the workaround for now; it really helps to have accurate line numbers when debugging.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood
commented
Aug 2, 2023
I had an idea for how to deduplicate some code between |
AlexWaygood
left a comment
There was a problem hiding this comment.
One last suggestion to help future maintainers -- looks great to me otherwise!
Uh oh!
There was an error while loading. Please reload this page.
erlend-aasland
commented
Aug 2, 2023
Great, thank you; this PR is in a lot better shape now 😄 |
Introduce ClinicError and ClinicWarning:
In main(), catch ClinicError, format the error message,
print to stderr, and exit with an error. Adapt the test
suite accordingly.
Tools/clinic/#104683