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

[3.14] gh-133980: use atomic store inPyObject_GenericSetDict (GH-133988)#134354

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
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
gh-133980: use atomic store inPyObject_GenericSetDict (GH-133988)
(cherry picked from commitec39fd2)Co-authored-by: Kumar Aditya <kumaraditya@python.org>
  • Loading branch information
@kumaraditya303@miss-islington
kumaraditya303 authored andmiss-islington committedMay 20, 2025
commit4ad0caf6e614b82682471da106f11b0a0ee21dc4
16 changes: 16 additions & 0 deletionsLib/test/test_free_threading/test_dict.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -228,6 +228,22 @@ def reader_func():

self.assertEqual(count,0)

deftest_racing_object_get_set_dict(self):
e=Exception()

defwriter():
foriinrange(10000):
e.__dict__= {1:2}

defreader():
foriinrange(10000):
e.__dict__

t1=Thread(target=writer)
t2=Thread(target=reader)

withthreading_helper.start_threads([t1,t2]):
pass

if__name__=="__main__":
unittest.main()
8 changes: 7 additions & 1 deletionObjects/object.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1931,7 +1931,13 @@ PyObject_GenericSetDict(PyObject *obj, PyObject *value, void *context)
return-1;
}
Py_BEGIN_CRITICAL_SECTION(obj);
Py_XSETREF(*dictptr,Py_NewRef(value));
PyObject*olddict=*dictptr;
FT_ATOMIC_STORE_PTR_RELEASE(*dictptr,Py_NewRef(value));
#ifdefPy_GIL_DISABLED
_PyObject_XDecRefDelayed(olddict);
#else
Py_XDECREF(olddict);
#endif
Py_END_CRITICAL_SECTION();
return0;
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp