Closed pjritee closed 9 years ago
In the later tuple example I get too many values to unpack (expected 2) If I remember correctly the old version would highlight the line of code where the error occurred - is that possible? I think it would be a big help for students to see the offending line of code highlighted.
Can you please provide a concrete example of what leads to code which is not highlighted but which you believe should be?
I have it set to highlight any errors which have associated line numbers. I expected to have issues with the wrapper (ie, with inserting other code around the student's code where they are not defining a function), but I haven't experienced them in practice. Maybe you've finally found one.
The code I gave above correctly gives the "string index out of range error" but it does not highlight the line print(chars[len(chars)]) (at least not for me)
Ok, I understand now; that's a different issue to what I thought. It's also a lot more difficult, as you're talking about catching runtime errors. (Compile errors are already handled.)
It's certainly possible, albeit hacky, to extract the traceback, and therefore the error line, from an exception; see here.
The difficult part is that different tests could cause different runtime errors. This would therefore need to be handled on a per-test basis. That's doable, just a bit fiddly. (It would also almost certainly involve the line offset issue I mentioned earlier, though that's no big deal.)
For the code:
I get (correctly)
That could be somewhat challenging for a student to figure out but I am not sure what can be done. Commenting out different print statements and trying again can focus the users attention but that might be asking too much of a student.