|
87 | 87 | import java.util.concurrent.locks.ReentrantLock;
|
88 | 88 | import java.util.logging.Level;
|
89 | 89 |
|
90 |
| -import com.oracle.graal.python.builtins.objects.contextvars.PContextVarsContext; |
91 | 90 | import org.graalvm.nativeimage.ImageInfo;
|
92 | 91 | import org.graalvm.options.OptionKey;
|
93 | 92 |
|
|
109 | 108 | import com.oracle.graal.python.builtins.objects.common.HashingStorage;
|
110 | 109 | import com.oracle.graal.python.builtins.objects.common.HashingStorageLibrary;
|
111 | 110 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
|
| 111 | +import com.oracle.graal.python.builtins.objects.contextvars.PContextVarsContext; |
112 | 112 | import com.oracle.graal.python.builtins.objects.dict.PDict;
|
113 | 113 | import com.oracle.graal.python.builtins.objects.frame.PFrame;
|
114 | 114 | import com.oracle.graal.python.builtins.objects.frame.PFrame.Reference;
|
@@ -247,9 +247,13 @@ public static final class PythonThreadState {
|
247 | 247 | /* The event currently being traced, only useful if tracing is true. */
|
248 | 248 | TraceEvent tracingWhat;
|
249 | 249 |
|
250 |
| - boolean contextInitialized = false; |
| 250 | + /* |
| 251 | + * tracks whether a contextVarsContext was ever set. This is useful to make bugs where |
| 252 | + * contextVarsContext gets set to null noticable. |
| 253 | + */ |
| 254 | + boolean contextVarsContextInitialized = false; |
251 | 255 |
|
252 |
| - PContextVarsContext context; |
| 256 | + PContextVarsContext contextVarsContext; |
253 | 257 |
|
254 | 258 | /*
|
255 | 259 | * The constructor needs to have this particular signature such that we can use it for
|
@@ -335,15 +339,16 @@ public void setNativeWrapper(PThreadState nativeWrapper) {
|
335 | 339 | }
|
336 | 340 |
|
337 | 341 | public PContextVarsContext getContextVarsContext() {
|
338 |
| - if (!contextInitialized) { |
339 |
| - context = PythonObjectFactory.getUncached().createContextVarsContext(); |
340 |
| - contextInitialized = true; |
| 342 | + if (!contextVarsContextInitialized) { |
| 343 | + contextVarsContext = PythonObjectFactory.getUncached().createContextVarsContext(); |
| 344 | + contextVarsContextInitialized = true; |
341 | 345 | }
|
342 |
| - return context; |
| 346 | + return contextVarsContext; |
343 | 347 | }
|
344 | 348 |
|
345 |
| - public void setContext(PContextVarsContext context) { |
346 |
| - this.context = context; |
| 349 | + public void setContextVarsContext(PContextVarsContext contextVarsContext) { |
| 350 | + this.contextVarsContext = contextVarsContext; |
| 351 | + this.contextVarsContextInitialized = true; |
347 | 352 | }
|
348 | 353 |
|
349 | 354 | public void dispose() {
|
|
0 commit comments