Skip to content

Commit ae41301

Browse files
author
Adam Hrbac
committed
Fix contains behaviour
1 parent 5cadf1a commit ae41301

File tree

1 file changed

+3
-2
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars

1 file changed

+3
-2
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
@@ -129,12 +129,13 @@ Object doGetDefault(PContextVarsContext self, Object key, Object def,
129129
@GenerateNodeFactory
130130
public abstract static class Contains extends PythonBuiltinNode {
131131
@Specialization
132-
boolean doIn(PContextVarsContext self, Object key) {
132+
boolean doIn(PContextVarsContext self, Object key,
133+
@Cached PRaiseNode raise) {
133134
if (key instanceof PContextVar) {
134135
PContextVar var = (PContextVar) key;
135136
return self.contextVarValues.lookup(var, var.getHash()) != null;
136137
}
137-
return false;
138+
throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CONTEXTVAR_KEY_EXPECTED, key);
138139
}
139140
}
140141

0 commit comments

Comments
 (0)