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

Appearance settings

Commit 9b9cdb6

Browse filesBrowse files
gh-100926: use explicit stginfo lock for pointer cache (#133867)
1 parent c838e21 commit 9b9cdb6
Copy full SHA for 9b9cdb6

File tree

2 files changed

+12
-18
lines changed
Filter options

2 files changed

+12
-18
lines changed

‎Modules/_ctypes/_ctypes.c

Copy file name to clipboardExpand all lines: Modules/_ctypes/_ctypes.c
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,14 +578,13 @@ _ctypes_CType_Type___sizeof___impl(PyObject *self, PyTypeObject *cls)
578578

579579
/*[clinic input]
580580
@getter
581-
@critical_section
582581
_ctypes.CType_Type.__pointer_type__
583582
584583
[clinic start generated code]*/
585584

586585
static PyObject *
587586
_ctypes_CType_Type___pointer_type___get_impl(PyObject *self)
588-
/*[clinic end generated code: output=718c9ff10b2b0012 input=ff7498aa6edf487c]*/
587+
/*[clinic end generated code: output=718c9ff10b2b0012 input=ad12dc835943ceb8]*/
589588
{
590589
ctypes_state *st = get_module_state_by_def(Py_TYPE(self));
591590
StgInfo *info;
@@ -596,9 +595,12 @@ _ctypes_CType_Type___pointer_type___get_impl(PyObject *self)
596595
PyErr_Format(PyExc_TypeError, "%R must have storage info", self);
597596
return NULL;
598597
}
599-
600-
if (info->pointer_type) {
601-
return Py_NewRef(info->pointer_type);
598+
PyObject *pointer_type;
599+
STGINFO_LOCK(info);
600+
pointer_type = Py_XNewRef(info->pointer_type);
601+
STGINFO_UNLOCK();
602+
if (pointer_type) {
603+
return pointer_type;
602604
}
603605

604606
PyErr_Format(PyExc_AttributeError,
@@ -609,14 +611,13 @@ _ctypes_CType_Type___pointer_type___get_impl(PyObject *self)
609611

610612
/*[clinic input]
611613
@setter
612-
@critical_section
613614
_ctypes.CType_Type.__pointer_type__
614615
615616
[clinic start generated code]*/
616617

617618
static int
618619
_ctypes_CType_Type___pointer_type___set_impl(PyObject *self, PyObject *value)
619-
/*[clinic end generated code: output=6259be8ea21693fa input=9b2dc2400c388982]*/
620+
/*[clinic end generated code: output=6259be8ea21693fa input=a05055fc7f4714b6]*/
620621
{
621622
ctypes_state *st = get_module_state_by_def(Py_TYPE(self));
622623
StgInfo *info;
@@ -627,8 +628,9 @@ _ctypes_CType_Type___pointer_type___set_impl(PyObject *self, PyObject *value)
627628
PyErr_Format(PyExc_TypeError, "%R must have storage info", self);
628629
return -1;
629630
}
630-
631+
STGINFO_LOCK(info);
631632
Py_XSETREF(info->pointer_type, Py_XNewRef(value));
633+
STGINFO_UNLOCK();
632634
return 0;
633635
}
634636

‎Modules/_ctypes/clinic/_ctypes.c.h

Copy file name to clipboardExpand all lines: Modules/_ctypes/clinic/_ctypes.c.h
+2-10Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.