Skip to content

Commit 53f522d

Browse files
committed
[3.13] pythongh-127082: Replace "Windows only" with the availability: Windows in ctypes doc (pythonGH-127099)
(cherry picked from commit 3c770e3) Co-authored-by: Jun Komoda <[email protected]>
1 parent 7bbcd32 commit 53f522d

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

Doc/library/ctypes.rst

+45-14
Original file line numberDiff line numberDiff line change
@@ -1395,13 +1395,15 @@ way is to instantiate one of the following classes:
13951395

13961396
.. class:: OleDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=None)
13971397

1398-
Windows only: Instances of this class represent loaded shared libraries,
1398+
Instances of this class represent loaded shared libraries,
13991399
functions in these libraries use the ``stdcall`` calling convention, and are
14001400
assumed to return the windows specific :class:`HRESULT` code. :class:`HRESULT`
14011401
values contain information specifying whether the function call failed or
14021402
succeeded, together with additional error code. If the return value signals a
14031403
failure, an :class:`OSError` is automatically raised.
14041404

1405+
.. availability:: Windows
1406+
14051407
.. versionchanged:: 3.3
14061408
:exc:`WindowsError` used to be raised,
14071409
which is now an alias of :exc:`OSError`.
@@ -1413,14 +1415,17 @@ way is to instantiate one of the following classes:
14131415

14141416
.. class:: WinDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=None)
14151417

1416-
Windows only: Instances of this class represent loaded shared libraries,
1418+
Instances of this class represent loaded shared libraries,
14171419
functions in these libraries use the ``stdcall`` calling convention, and are
14181420
assumed to return :c:expr:`int` by default.
14191421

1422+
.. availability:: Windows
1423+
14201424
.. versionchanged:: 3.12
14211425

14221426
The *name* parameter can now be a :term:`path-like object`.
14231427

1428+
14241429
The Python :term:`global interpreter lock` is released before calling any
14251430
function exported by these libraries, and reacquired afterwards.
14261431

@@ -1556,13 +1561,17 @@ These prefabricated library loaders are available:
15561561
.. data:: windll
15571562
:noindex:
15581563

1559-
Windows only: Creates :class:`WinDLL` instances.
1564+
Creates :class:`WinDLL` instances.
1565+
1566+
.. availability:: Windows
15601567

15611568

15621569
.. data:: oledll
15631570
:noindex:
15641571

1565-
Windows only: Creates :class:`OleDLL` instances.
1572+
Creates :class:`OleDLL` instances.
1573+
1574+
.. availability:: Windows
15661575

15671576

15681577
.. data:: pydll
@@ -1734,11 +1743,13 @@ See :ref:`ctypes-callback-functions` for examples.
17341743

17351744
.. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
17361745

1737-
Windows only: The returned function prototype creates functions that use the
1746+
The returned function prototype creates functions that use the
17381747
``stdcall`` calling convention. The function will
17391748
release the GIL during the call. *use_errno* and *use_last_error* have the
17401749
same meaning as above.
17411750

1751+
.. availability:: Windows
1752+
17421753

17431754
.. function:: PYFUNCTYPE(restype, *argtypes)
17441755

@@ -1964,17 +1975,21 @@ Utility functions
19641975

19651976
.. function:: DllCanUnloadNow()
19661977

1967-
Windows only: This function is a hook which allows implementing in-process
1978+
This function is a hook which allows implementing in-process
19681979
COM servers with ctypes. It is called from the DllCanUnloadNow function that
19691980
the _ctypes extension dll exports.
19701981

1982+
.. availability:: Windows
1983+
19711984

19721985
.. function:: DllGetClassObject()
19731986

1974-
Windows only: This function is a hook which allows implementing in-process
1987+
This function is a hook which allows implementing in-process
19751988
COM servers with ctypes. It is called from the DllGetClassObject function
19761989
that the ``_ctypes`` extension dll exports.
19771990

1991+
.. availability:: Windows
1992+
19781993

19791994
.. function:: find_library(name)
19801995
:module: ctypes.util
@@ -1990,28 +2005,35 @@ Utility functions
19902005
.. function:: find_msvcrt()
19912006
:module: ctypes.util
19922007

1993-
Windows only: return the filename of the VC runtime library used by Python,
2008+
Returns the filename of the VC runtime library used by Python,
19942009
and by the extension modules. If the name of the library cannot be
19952010
determined, ``None`` is returned.
19962011

19972012
If you need to free memory, for example, allocated by an extension module
19982013
with a call to the ``free(void *)``, it is important that you use the
19992014
function in the same library that allocated the memory.
20002015

2016+
.. availability:: Windows
2017+
20012018

20022019
.. function:: FormatError([code])
20032020

2004-
Windows only: Returns a textual description of the error code *code*. If no
2021+
Returns a textual description of the error code *code*. If no
20052022
error code is specified, the last error code is used by calling the Windows
20062023
api function GetLastError.
20072024

2025+
.. availability:: Windows
2026+
20082027

20092028
.. function:: GetLastError()
20102029

2011-
Windows only: Returns the last error code set by Windows in the calling thread.
2030+
Returns the last error code set by Windows in the calling thread.
20122031
This function calls the Windows ``GetLastError()`` function directly,
20132032
it does not return the ctypes-private copy of the error code.
20142033

2034+
.. availability:: Windows
2035+
2036+
20152037
.. function:: get_errno()
20162038

20172039
Returns the current value of the ctypes-private copy of the system
@@ -2021,11 +2043,14 @@ Utility functions
20212043

20222044
.. function:: get_last_error()
20232045

2024-
Windows only: returns the current value of the ctypes-private copy of the system
2046+
Returns the current value of the ctypes-private copy of the system
20252047
:data:`!LastError` variable in the calling thread.
20262048

2049+
.. availability:: Windows
2050+
20272051
.. audit-event:: ctypes.get_last_error "" ctypes.get_last_error
20282052

2053+
20292054
.. function:: memmove(dst, src, count)
20302055

20312056
Same as the standard C memmove library function: copies *count* bytes from
@@ -2074,10 +2099,12 @@ Utility functions
20742099

20752100
.. function:: set_last_error(value)
20762101

2077-
Windows only: set the current value of the ctypes-private copy of the system
2102+
Sets the current value of the ctypes-private copy of the system
20782103
:data:`!LastError` variable in the calling thread to *value* and return the
20792104
previous value.
20802105

2106+
.. availability:: Windows
2107+
20812108
.. audit-event:: ctypes.set_last_error error ctypes.set_last_error
20822109

20832110

@@ -2098,12 +2125,14 @@ Utility functions
20982125

20992126
.. function:: WinError(code=None, descr=None)
21002127

2101-
Windows only: this function is probably the worst-named thing in ctypes. It
2128+
This function is probably the worst-named thing in ctypes. It
21022129
creates an instance of :exc:`OSError`. If *code* is not specified,
21032130
``GetLastError`` is called to determine the error code. If *descr* is not
21042131
specified, :func:`FormatError` is called to get a textual description of the
21052132
error.
21062133

2134+
.. availability:: Windows
2135+
21072136
.. versionchanged:: 3.3
21082137
An instance of :exc:`WindowsError` used to be created, which is now an
21092138
alias of :exc:`OSError`.
@@ -2443,9 +2472,11 @@ These are the fundamental ctypes data types:
24432472

24442473
.. class:: HRESULT
24452474

2446-
Windows only: Represents a :c:type:`!HRESULT` value, which contains success or
2475+
Represents a :c:type:`!HRESULT` value, which contains success or
24472476
error information for a function or method call.
24482477

2478+
.. availability:: Windows
2479+
24492480

24502481
.. class:: py_object
24512482

0 commit comments

Comments
 (0)