Skip to content
Navigation Menu
{{ message }}
This repository was archived by the owner on May 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
chore: Restore code coverage #855
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
|
|
||
| import collections | ||
| import contextlib | ||
| import contextvars | ||
| import itertools | ||
| import os | ||
| import six | ||
|
|
@@ -60,43 +61,30 @@ def __next__(self): | |
| _context_ids = _ContextIds() | ||
|
|
||
|
|
||
| try: # pragma: NO PY2 COVER | ||
| import contextvars | ||
| class _LocalState: | ||
| """Thread local state.""" | ||
|
|
||
| class _LocalState: | ||
| """Thread local state.""" | ||
|
|
||
| def __init__(self): | ||
| self._toplevel_context = contextvars.ContextVar( | ||
| "_toplevel_context", default=None | ||
| ) | ||
| self._context = contextvars.ContextVar("_context", default=None) | ||
|
|
||
| @property | ||
| def context(self): | ||
| return self._context.get() | ||
|
|
||
| @context.setter | ||
| def context(self, value): | ||
| self._context.set(value) | ||
|
|
||
| @property | ||
| def toplevel_context(self): | ||
| return self._toplevel_context.get() | ||
|
|
||
| @toplevel_context.setter | ||
| def toplevel_context(self, value): | ||
| self._toplevel_context.set(value) | ||
| def __init__(self): | ||
| self._toplevel_context = contextvars.ContextVar( | ||
| "_toplevel_context", default=None | ||
| ) | ||
| self._context = contextvars.ContextVar("_context", default=None) | ||
|
|
||
| @property | ||
| def context(self): | ||
| return self._context.get() | ||
|
|
||
| except ImportError: # pragma: NO PY3 COVER | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: it's easier to see that this change is correct if you view it with split-diffs and while ignoring whitespace changes |
||
| @context.setter | ||
| def context(self, value): | ||
| self._context.set(value) | ||
|
|
||
| class _LocalState(threading.local): | ||
| """Thread local state.""" | ||
| @property | ||
| def toplevel_context(self): | ||
| return self._toplevel_context.get() | ||
|
|
||
| def __init__(self): | ||
| self.context = None | ||
| self.toplevel_context = None | ||
| @toplevel_context.setter | ||
| def toplevel_context(self, value): | ||
| self._toplevel_context.set(value) | ||
|
|
||
|
|
||
| _state = _LocalState() | ||
|
|
||
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
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
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
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
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
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
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.
You can’t perform that action at this time.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fromstringis a deprecated alias forfrombytes. Ditto fortostringvs.tobytes.The string versions date from Py2 and were renamed and aliased in Py3 due to the bytes/string distinction. The aliases were removed in Python 3.9.