| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@brettcannon Just checking in if you're waiting on me for anything. (No rush from my end.) |
Sorry, something went wrong.
|
@effigies Nope, I'm just swamped right now, so I haven't had time to do another review yet. |
Sorry, something went wrong.
|
No worries! I appreciate you taking the time, whenever you get it. |
Sorry, something went wrong.
There was a problem hiding this comment.
Some minor tweaks, but otherwise LGTM!
Sorry, something went wrong.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request. |
Sorry, something went wrong.
Co-authored-by: Brett Cannon <brett@python.org>
|
@bedevere-bot I have made the requested changes; please review again. |
Sorry, something went wrong.
| loader_state['__dict__'] = module.__dict__.copy() | ||
| loader_state['__class__'] = module.__class__ | ||
| loader_state['lock'] = threading.RLock() | ||
| loader_state['is_loading'] = threading.Event() |
There was a problem hiding this comment.
Hi, can we use a bool flag instead of threading.Event? I see that access and modification to loader_state['is_loading'] is protected by the loader_state['lock'], so there is no thread safety issue.
Using an additional threading.Event would introduce unnecessary resource costs.
Sorry, something went wrong.
There was a problem hiding this comment.
I agree, good catch. I will switch to a bool and push later today.
Sorry, something went wrong.
|
!buildbot wasi |
Sorry, something went wrong.
|
🤖 New build scheduled with the buildbot fleet by @brettcannon for commit 023d65d 🤖 The command will test the builders whose names match following regular expression: wasi The builders matched are:
|
Sorry, something went wrong.
|
Thanks @effigies for the PR, and @brettcannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
Sorry, something went wrong.
…aces (pythonGH-114781) Setting the __class__ attribute of a lazy-loading module to ModuleType enables other threads to attempt to access attributes before the loading is complete. Now that is protected by a lock. (cherry picked from commit 200271c) Co-authored-by: Chris Markiewicz <effigies@gmail.com>
|
GH-115870 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
…aces (pythonGH-114781) Setting the __class__ attribute of a lazy-loading module to ModuleType enables other threads to attempt to access attributes before the loading is complete. Now that is protected by a lock. (cherry picked from commit 200271c) Co-authored-by: Chris Markiewicz <effigies@gmail.com>
|
GH-115871 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
…races (GH-114781) (GH-115870) gh-114763: Protect lazy loading modules from attribute access races (GH-114781) Setting the __class__ attribute of a lazy-loading module to ModuleType enables other threads to attempt to access attributes before the loading is complete. Now that is protected by a lock. (cherry picked from commit 200271c) Co-authored-by: Chris Markiewicz <effigies@gmail.com>
…races (GH-114781) (GH-115871) gh-114763: Protect lazy loading modules from attribute access races (GH-114781) Setting the __class__ attribute of a lazy-loading module to ModuleType enables other threads to attempt to access attributes before the loading is complete. Now that is protected by a lock. (cherry picked from commit 200271c) Co-authored-by: Chris Markiewicz <effigies@gmail.com>
…aces (pythonGH-114781) Setting the __class__ attribute of a lazy-loading module to ModuleType enables other threads to attempt to access attributes before the loading is complete. Now that is protected by a lock.
|
Please see #117178 for a potential regression in 3.11 - 3.13. |
Sorry, something went wrong.
…aces (pythonGH-114781) Setting the __class__ attribute of a lazy-loading module to ModuleType enables other threads to attempt to access attributes before the loading is complete. Now that is protected by a lock.
…aces (pythonGH-114781) Setting the __class__ attribute of a lazy-loading module to ModuleType enables other threads to attempt to access attributes before the loading is complete. Now that is protected by a lock.
| Back | FazBrowse Home | New Git URL |
As described in #114763, setting the __class__ attribute of a lazy-loading module to ModuleType enables other threads to attempt to access attributes before the loading is complete. This PR moves self.__class__ = types.ModuleType to be the final act.
This requires two additional pieces to work:
The Event needs to be tied to the specific module, so I also tied the lock to the module, as opposed to a lock scoped to the importlib.util module. I used object.__getattribute__() for __spec__ and __dict__, which were previously accessed directly after self.__class__ was reset.
Otherwise, I tried to keep things as close as possible to the original. I will try to write a unit test fitting with the module style, but the minimal reproduction in the issue is resolved by these changes.
Closes #114763