forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 2
Add WriteBarrier to dictobject #34
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e0c7f68
Add WriteBarrier to dictobject
mjp41 e835682
Fix merge
mjp41 a49c15b
Fix add referece to modiy LRC
mjp41 22225c0
Fix merge
mjp41 398e6d4
Fix UAF
mjp41 69eb8bd
Fixing some UAF potential scenarios.
mjp41 956ee53
Warnings.
mjp41 ff38aa0
Fix merge
mjp41 d8b2390
Py_CLEAR
mjp41 b1ef1f9
Fixes
mjp41 708f368
Handle dict.update(...) correctly
mjp41 3aebba0
Make Py_CLEAR_OBJECT_FIELD same as Py_CLEAR with extra remove
mjp41 8ddf486
Format
mjp41 ea27948
Fix PyClear variant.
mjp41 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import unittest | ||
|
|
||
| class TestRegionsDictObject(unittest.TestCase): | ||
| def setUp(self): | ||
| enableinvariant() | ||
|
|
||
| def test_dict_insert_empty_dict(self): | ||
| # Create Region with Empty dictionary | ||
| r = Region() | ||
| d = {} | ||
| r.body = d | ||
| n = {} | ||
| # Add local object to region | ||
| d["foo"] = n | ||
| self.assertTrue(r.owns_object(n)) | ||
|
|
||
| def test_dict_insert_nonempty_dict(self): | ||
| # Create Region with Nonempty dictionary | ||
| r = Region() | ||
| d = {} | ||
| d["bar"] = 1 | ||
| r.body = d | ||
| # Add local object to region | ||
| n = {} | ||
| d["foo"] = n | ||
| self.assertTrue(r.owns_object(n)) | ||
|
|
||
| def test_dict_update_dict(self): | ||
| # Create Region with Nonempty dictionary | ||
| r = Region() | ||
| d = {} | ||
| n1 = {} | ||
| d["foo"] = n1 | ||
| r.body = d | ||
| # Update dictionary to contain a local object | ||
| n2 = {} | ||
| d["foo"] = n2 | ||
| self.assertTrue(r.owns_object(n2)) | ||
|
|
||
| def test_dict_clear(self): | ||
| # Create Region with Nonempty dictionary | ||
| r = Region() | ||
| d = {} | ||
| n = {} | ||
| d["foo"] = n | ||
| r.body = d | ||
| # Clear dictionary | ||
| d.clear() | ||
| # As LRC is not checked by the invariant, this test cannot | ||
| # check anything useful yet. | ||
|
|
||
| def test_dict_copy(self): | ||
| r = Region() | ||
| d = {} | ||
| r.body = d | ||
| r2 = Region() | ||
| d["foo"] = r2 | ||
| d.copy() | ||
|
|
||
| def test_dict_setdefault(self): | ||
| r = Region("outer") | ||
| d = {} | ||
| r.body = d | ||
| r2 = Region("inner") | ||
| d["foo"] = r2 | ||
| d.setdefault("foo", r2) | ||
| self.assertRaises(RegionError, d.setdefault, "bar", r2) | ||
|
|
||
| def test_dict_update(self): | ||
| # Create a region containing two dictionaries | ||
| r = Region() | ||
| d = {} | ||
| r.body = d | ||
| d2 = {} | ||
| r.body2 = d2 | ||
| # Add a contained region to the first dictionary | ||
| d["reg"] = Region() | ||
| # Update the second dictionary to contain the elements of the first | ||
| self.assertRaises(RegionError, d2.update, d) | ||
| self.assertRaises(RegionError, d2.update, d) |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Thanks for the renaming! 🙏