Skip to content

Commit 6515f63

Browse files
authored
Merge branch 'main' into gh158198
2 parents cb395c0 + 0b8bb71 commit 6515f63

52 files changed

Lines changed: 1864 additions & 875 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/reusable-wasi.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
timeout-minutes: 60
1717
env:
1818
WASMTIME_VERSION: 48.0.2
19-
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
2019
steps:
2120
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2221
with:
@@ -65,4 +64,6 @@ jobs:
6564
- name: "Display build info of the host/WASI Python"
6665
run: python3 Platforms/WASI pythoninfo-host
6766
- name: "Test"
68-
run: make --directory "${CROSS_BUILD_WASI}" test
67+
run: |
68+
CROSS_BUILD_WASI=$(python3 Platforms/WASI path)
69+
make --directory "${CROSS_BUILD_WASI}" test

‎Doc/library/ctypes.rst‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,31 @@ write::
13371337
:class:`threading.local` will *not* survive across different callbacks, even when
13381338
those calls are made from the same C thread.
13391339

1340+
Callback functions can return structures and unions by value, in addition to
1341+
the simple types:
1342+
1343+
.. code-block:: python
1344+
1345+
class Point(Structure):
1346+
_fields_ = [("x", c_int), ("y", c_int)]
1347+
1348+
@CFUNCTYPE(Point)
1349+
def get_origin():
1350+
return Point(0, 0)
1351+
1352+
.. note::
1353+
1354+
A structure or union returned from a callback is copied *by value*, and
1355+
:mod:`!ctypes` does not keep the returned object alive after the callback
1356+
returns. If the structure contains a pointer field (such as
1357+
:class:`c_char_p` or a :func:`POINTER` type), you must ensure that the
1358+
memory it refers to stays valid for as long as the C code uses it -- the
1359+
same requirement C itself imposes. Returning a pointer to memory owned by
1360+
a temporary Python object will leave the C caller with a dangling pointer.
1361+
1362+
.. versionchanged:: next
1363+
Callback functions can now return structures and unions.
1364+
13401365
.. _ctypes-accessing-values-exported-from-dlls:
13411366

13421367
Accessing values exported from dlls

‎Doc/library/zipfile.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,10 @@ Path objects are traversable using the ``/`` operator or ``joinpath``.
722722

723723
Enumerate the children of the current directory.
724724

725+
.. versionchanged:: 3.16
726+
Raises :exc:`NotADirectoryError` when the current context does not
727+
reference a directory. Previously, it raised :exc:`ValueError`.
728+
725729
.. method:: Path.is_dir()
726730

727731
Return ``True`` if the current context references a directory.

‎Doc/whatsnew/3.16.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ ctypes
244244
implicitly converted when passed for a :func:`~ctypes.POINTER` argument.
245245
(Contributed by Peter Bierma in :gh:`71990`.)
246246

247+
* :ref:`Callback functions <ctypes-callback-functions>` can now return
248+
:class:`~ctypes.Structure` and :class:`~ctypes.Union` instances by value.
249+
(Contributed by Russell Keith-Magee in :gh:`49960`.)
250+
247251

248252
curses
249253
------

0 commit comments

Comments
 (0)