Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-114763: Protect lazy loading modules from attribute access race#114781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
brettcannon merged 12 commits intopython:mainfromeffigies:fix-issue-114763
Feb 24, 2024
Merged
Changes from1 commit
Commits
Show all changes
12 commits
Select commitHold shift + click to select a range
d57f4eb
gh-114763: Protect lazy loading modules from attribute access race
effigiesJan 31, 2024
3db717c
TEST: Reproduce gh-114763
effigiesJan 31, 2024
5424d0c
Add new blurb
effigiesJan 31, 2024
96c08c5
Improve comments around the branching
effigiesFeb 1, 2024
3642ddc
TEST: Use TestCase.assert* methods
effigiesFeb 1, 2024
46238e5
Merge branch 'main' into fix-issue-114763
brettcannonFeb 6, 2024
6accf0c
Apply suggestions from code review
effigiesFeb 17, 2024
bb2292f
TEST: Require working threading for test_module_load_race
effigiesFeb 17, 2024
57fe084
Move threading import to module level of importlib.util
effigiesFeb 17, 2024
40383a0
Make is_loading a bool instead of Event
effigiesFeb 17, 2024
6322dd6
Merge branch 'main' into fix-issue-114763
effigiesFeb 23, 2024
023d65d
Merge branch 'main' into fix-issue-114763
brettcannonFeb 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Make is_loading a bool instead of Event
  • Loading branch information
@effigies
effigies committedFeb 17, 2024
commit40383a049de3d72382adc1481fce9fcb32465bea
6 changes: 3 additions & 3 deletionsLib/importlib/util.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -183,9 +183,9 @@ def __getattribute__(self, attr):
# exec_module(), which will access module.__dict__, module.__name__,
# and/or module.__spec__, reentering this method. These accesses
# need to be allowed to proceed without triggering the load again.
if loader_state['is_loading'].is_set() and attr.startswith('__') and attr.endswith('__'):
if loader_state['is_loading'] and attr.startswith('__') and attr.endswith('__'):
return object.__getattribute__(self, attr)
loader_state['is_loading'].set()
loader_state['is_loading'] = True

__dict__ = object.__getattribute__(self, '__dict__')

Expand DownExpand Up@@ -264,6 +264,6 @@ def exec_module(self, module):
loader_state['__dict__'] = module.__dict__.copy()
loader_state['__class__'] = module.__class__
loader_state['lock'] = threading.RLock()
loader_state['is_loading'] =threading.Event()
loader_state['is_loading'] =False
module.__spec__.loader_state = loader_state
module.__class__ = _LazyModule

[8]ページ先頭

©2009-2025 Movatter.jp