Skip to content

Commit 7a7e2c9

Browse files
author
Philip Guo
committed
chugging along
1 parent 79f5c7d commit 7a7e2c9

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

edu-python-questions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ reverse(input)\n";
7575
{user_script : submittedCode},
7676
function(traceData) {
7777
renderPyCodeOutput(submittedCode);
78-
processTrace(traceData);
78+
processTrace(traceData, true);
7979

8080
$("#pyInputPane").hide();
8181
$("#pyOutputPane").show();

edu-python-tutor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ $(document).ready(function() {
4343
{user_script : $("#pyInput").val()},
4444
function(traceData) {
4545
renderPyCodeOutput($("#pyInput").val());
46-
processTrace(traceData);
46+
processTrace(traceData, false);
4747

4848
$("#pyInputPane").hide();
4949
$("#pyOutputPane").show();

edu-python.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function htmlspecialchars(str) {
7777
return str;
7878
}
7979

80-
function processTrace(traceData) {
80+
function processTrace(traceData, jumpToEnd) {
8181
curTrace = traceData;
8282
curInstr = 0;
8383

@@ -91,22 +91,6 @@ function processTrace(traceData) {
9191
// GLOBAL!
9292
instrLimitReached = (lastEntry.event == 'instruction_limit_reached');
9393

94-
// if there is some sort of error, then JUMP to it so that we can
95-
// immediately alert the user:
96-
// (cgi-bin/pg_logger.py ensures that if there is an uncaught
97-
// exception, then that exception event will be the FINAL
98-
// entry in curTrace. a caught exception will appear somewhere in
99-
// the MIDDLE of curTrace)
100-
//
101-
// on second thought, let's hold off on that for now
102-
103-
/*
104-
if (lastEntry.event == 'exception' ||
105-
lastEntry.event == 'uncaught_exception') {
106-
// updateOutput should take care of the rest ...
107-
curInstr = curTrace.length - 1;
108-
}
109-
*/
11094
if (instrLimitReached) {
11195
curTrace.pop() // kill last entry
11296
var warningMsg = lastEntry.exception_msg;
@@ -118,6 +102,23 @@ function processTrace(traceData) {
118102
else if (curTrace.length == 2) {
119103
curTrace.shift();
120104
}
105+
106+
107+
if (jumpToEnd) {
108+
// if there's an exception, then jump to the FIRST occurrence of
109+
// that exception. otherwise, jump to the very end of execution.
110+
curInstr = curTrace.length - 1;
111+
112+
for (var i = 0; i < curTrace.length; i++) {
113+
var curEntry = curTrace[i];
114+
if (curEntry.event == 'exception' ||
115+
curEntry.event == 'uncaught_exception') {
116+
curInstr = i;
117+
break;
118+
}
119+
}
120+
}
121+
121122
}
122123

123124
updateOutput();

question.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@
138138

139139
<div id="footer">
140140

141+
<input type="checkbox" id="classicModeCheckbox"/> Use low-bandwidth mode (for older browsers)
142+
141143
<p/>
142144
This application supports the core <a
143145
href="http://www.python.org/doc/2.5/">Python 2.5</a> language, with no

0 commit comments

Comments
 (0)