Skip to content

Commit edaad94

Browse files
author
Adam Hrbac
committed
Avoid an uncached PRaiseNode when entering Context
1 parent 8403aba commit edaad94

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ Object get(PContextVarsContext self, Object key,
8585
public abstract static class Run extends PythonBuiltinNode {
8686
@Specialization
8787
Object get(VirtualFrame frame, PContextVarsContext self, Object fun, Object[] args, PKeyword[] keywords,
88-
@Cached CallNode call) {
88+
@Cached CallNode call,
89+
@Cached PRaiseNode raise) {
8990
PythonContext.PythonThreadState threadState = getContext().getThreadState(getLanguage());
90-
self.enter(threadState);
91+
self.enter(threadState, raise);
9192
try {
9293
return call.execute(frame, fun, args, keywords);
9394
} finally {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextVarsContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public class PContextVarsContext extends PythonBuiltinObject {
5151
Hamt contextVarValues;
5252
private PContextVarsContext previousContext = null;
5353

54-
public void enter(PythonContext.PythonThreadState threadState) {
54+
public void enter(PythonContext.PythonThreadState threadState, PRaiseNode raise) {
5555
if (previousContext != null) {
56-
throw PRaiseNode.getUncached().raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_ENTER_CONTEXT_ALREADY_ENTERED, this);
56+
throw raise.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_ENTER_CONTEXT_ALREADY_ENTERED, this);
5757
}
5858
previousContext = threadState.getContextVarsContext();
5959
assert previousContext != null : "ThreadState had null Context. This should not happen";

0 commit comments

Comments
 (0)