Skip to content

Commit af15bee

Browse files
committed
Fix: Consume exception if handled in expect* method.
1 parent 59dddfa commit af15bee

File tree

1 file changed

+8
-0
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception

1 file changed

+8
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/PException.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,27 +138,35 @@ public boolean isExit() {
138138
return exit;
139139
}
140140

141+
private static void popException(PythonCore core) {
142+
core.getContext().setCurrentException(null);
143+
}
144+
141145
public void expectIndexError(PythonCore core, ConditionProfile profile) {
142146
if (profile.profile(getType() != core.getErrorClass(PythonErrorType.IndexError))) {
143147
throw this;
144148
}
149+
popException(core);
145150
}
146151

147152
public void expectStopIteration(PythonCore core, ConditionProfile profile) {
148153
if (profile.profile(getType() != core.getErrorClass(PythonErrorType.StopIteration))) {
149154
throw this;
150155
}
156+
popException(core);
151157
}
152158

153159
public void expectAttributeError(PythonCore core, ConditionProfile profile) {
154160
if (profile.profile(getType() != core.getErrorClass(PythonErrorType.AttributeError))) {
155161
throw this;
156162
}
163+
popException(core);
157164
}
158165

159166
public void expect(PythonErrorType error, PythonCore core, ConditionProfile profile) {
160167
if (profile.profile(getType() != core.getErrorClass(error))) {
161168
throw this;
162169
}
170+
popException(core);
163171
}
164172
}

0 commit comments

Comments
 (0)