Parser: Normalize exception before reading values
ClosedPublic

Authored by flherne on Sep 21 2017, 10:07 AM.

Details

Reviewers
brauch
Summary

The Python C-API is pretty weird here. By calling PyErr_NormalizeException, we get an instance of SyntaxError (or its subclass IndentationError) as the value instead of a plain tuple, which makes things clearer.

Another effect is that we get the "Missing parentheses in call to 'print'" message when relevant instead of just "invalid syntax".

Test Plan

Parsing valid files still works, parsing broken files doesn't crash, and in case of python2 'print' or 'exec' statements we display the more detailed error.

Diff Detail

Repository
R53 KDevelop: Python Support
Lint
Lint Skipped
Unit
Unit Tests Skipped
flherne created this revision.Sep 21 2017, 10:07 AM
Restricted Application added a subscriber: kdevelop-devel. ยท View Herald TranscriptSep 21 2017, 10:07 AM
brauch accepted this revision.Sep 21 2017, 11:26 AM

Looks good to me, thanks!

This revision is now accepted and ready to land.Sep 21 2017, 11:26 AM