Repository navigation
Fix: Context variables shared between code don't work with greenlet > 0.4.1 - #1062
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1062 +/- ##
==========================================
- Coverage 76.51% 76.29% -0.22%
==========================================
Files 62 61 -1
Lines 8308 8459 +151
==========================================
+ Hits 6357 6454 +97
- Misses 1951 2005 +54 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #852
Summary
Fixes an issue where context variables (such as
contextvars.ContextVar) cannot be shared across multiple lines of input when running greenlet > 0.4.17.Root cause
_unload_code()was clearingself.code_contextby setting it toNoneevery time code finished running for a line, preventing the execution context from persisting across code runs.Changes
self.code_context = Nonefrom_unload_code()inbpython/curtsiesfrontend/coderunner.py.self.code_context = Noneonly when handlingDone,Unfinished, orSystemExitRequestresponses inrun_code().sigint_handler()inbpython/curtsiesfrontend/coderunner.pyto check thatself.code_contextis truthy before comparing it to the current greenlet.Testing
Syntax check passed on the changed file(s). The full test suite was not run locally, so I'm relying on CI to confirm.
AI-assisted.