Skip to content

Commit fa6a897

Browse files
authored
Merge branch 'main' into cleanup/315/ctypes-set-pointer-type-133866
2 parents a4c6700 + 13cb8ca commit fa6a897

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

Doc/whatsnew/3.15.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ ctypes
131131
sysconfig
132132
---------
133133

134-
* The *check_home* parameter of :func:`sysconfig.is_python_build`.
134+
* Removed the *check_home* parameter of :func:`sysconfig.is_python_build`.
135135
(Contributed by Filipe Laíns in :gh:`92897`.)
136136

137137

@@ -140,7 +140,7 @@ typing
140140

141141
* The undocumented keyword argument syntax for creating
142142
:class:`~typing.NamedTuple` classes (for example,
143-
``Point = NamedTuple("Point", x=int, y=int)``).
143+
``Point = NamedTuple("Point", x=int, y=int)``) is no longer supported.
144144
Use the class-based syntax or the functional syntax instead.
145145
(Contributed by Bénédikt Tran in :gh:`133817`.)
146146

@@ -211,6 +211,7 @@ Removed C APIs
211211

212212
* :c:func:`!PyImport_ImportModuleNoBlock`: deprecated alias
213213
of :c:func:`PyImport_ImportModule`.
214+
(Contributed by Bénédikt Tran in :gh:`133644`.)
214215

215216
The following functions are removed in favor of :c:func:`PyConfig_Get`.
216217
The |pythoncapi_compat_project| can be used to get :c:func:`!PyConfig_Get`
@@ -243,6 +244,8 @@ on Python 3.13 and older.
243244
use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the
244245
:envvar:`PYTHONHOME` environment variable instead.
245246

247+
(Contributed by Bénédikt Tran in :gh:`133644`.)
248+
246249
.. |pythoncapi_compat_project| replace:: |pythoncapi_compat_project_link|_
247250
.. |pythoncapi_compat_project_link| replace:: pythoncapi-compat project
248251
.. _pythoncapi_compat_project_link: https://github.com/python/pythoncapi-compat

Modules/_ctypes/_ctypes.c

Lines 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

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/stackrefs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include "Python.h"
32

43
#include "pycore_object.h"
@@ -34,6 +33,7 @@ make_table_entry(PyObject *obj, const char *filename, int linenumber)
3433
result->filename = filename;
3534
result->linenumber = linenumber;
3635
result->filename_borrow = NULL;
36+
result->linenumber_borrow = 0;
3737
return result;
3838
}
3939

0 commit comments

Comments
 (0)