8000 gh-128182: Add per-object memory access synchronization to `ctypes` by ZeroIntensity · Pull Request #128490 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-128182: Add per-object memory access synchronization to ctypes #128490

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 24 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Fix the test.
  • Loading branch information
ZeroIntensity committed Jan 4, 2025
commit da293c14262a946b00c08fa45aa3ea7dd2551fda
6 changes: 3 additions & 3 deletions Lib/test/test_ctypes/test_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
create_string_buffer, create_unicode_buffer,
c_char, c_wchar, c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint,
c_long, c_ulonglong, c_float, c_double, c_longdouble)
from test.support import bigmemtest, _2G, threading_helper
from test.support import bigmemtest, _2G, threading_helper, Py_GIL_DISABLED
from ._support import (_CData, PyCArrayType, Py_TPFLAGS_DISALLOW_INSTANTIATION,
Py_TPFLAGS_IMMUTABLETYPE)

Expand Down Expand Up @@ -268,7 +268,7 @@ def test_large_array(self, size):
c_char * size

@threading_helper.requires_working_threading()
@unittest.skipUnless(support.Py_GIL_DISABLED, "only meaningful if the GIL is disabled")
@unittest.skipUnless(Py_GIL_DISABLED, "only meaningful if the GIL is disabled")
def test_thread_safety(self):
from threading import Thread

Expand All @@ -280,7 +280,7 @@ def run():
buffer[0] = b"j"

with threading_helper.catch_threading_exception() as cm:
with threading_helper.start_threads((run for _ in range(25))):
with threading_helper.start_threads((Thread(target=run) for _ in range(25))):
pass

self.assertIsNone(cm.exc_value)
Expand Down
2 changes: 1 addition & 1 deletion Modules/_ctypes/ctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,6 @@ static inline void
locked_deref_assign(CDataObject *self, void *new_ptr)
{
LOCK_PTR(self);
*self->b_ptr = new_ptr;
*(void **)self->b_ptr = new_ptr;
UNLOCK_PTR(self);
}
0