Skip to content

Commit 3c770e3

Browse files
authored
gh-127082: Replace "Windows only" with the availability: Windows in ctypes doc (#127099)
1 parent 89125e9 commit 3c770e3

File tree

1 file changed

+48
-15
lines changed

1 file changed

+48
-15
lines changed

Doc/library/ctypes.rst

+48-15
Original file line numberDiff line numberDiff line change
@@ -1413,13 +1413,15 @@ way is to instantiate one of the following classes:
14131413

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

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

1423+
.. availability:: Windows
1424+
14231425
.. versionchanged:: 3.3
14241426
:exc:`WindowsError` used to be raised,
14251427
which is now an alias of :exc:`OSError`.
@@ -1431,14 +1433,17 @@ way is to instantiate one of the following classes:
14311433

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

1434-
Windows only: Instances of this class represent loaded shared libraries,
1436+
Instances of this class represent loaded shared libraries,
14351437
functions in these libraries use the ``stdcall`` calling convention, and are
14361438
assumed to return :c:expr:`int` by default.
14371439

1440+
.. availability:: Windows
1441+
14381442
.. versionchanged:: 3.12
14391443

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

1446+
14421447
The Python :term:`global interpreter lock` is released before calling any
14431448
function exported by these libraries, and reacquired afterwards.
14441449

@@ -1574,13 +1579,17 @@ These prefabricated library loaders are available:
15741579
.. data:: windll
15751580
:noindex:
15761581

1577-
Windows only: Creates :class:`WinDLL` instances.
1582+
Creates :class:`WinDLL` instances.
1583+
1584+
.. availability:: Windows
15781585

15791586

15801587
.. data:: oledll
15811588
:noindex:
15821589

1583-
Windows only: Creates :class:`OleDLL` instances.
1590+
Creates :class:`OleDLL` instances.
1591+
1592+
.. availability:: Windows
15841593

15851594

15861595
.. data:: pydll
@@ -1746,11 +1755,13 @@ See :ref:`ctypes-callback-functions` for examples.
17461755

17471756
.. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
17481757

1749-
Windows only: The returned function prototype creates functions that use the
1758+
The returned function prototype creates functions that use the
17501759
``stdcall`` calling convention. The function will
17511760
release the GIL during the call. *use_errno* and *use_last_error* have the
17521761
same meaning as above.
17531762

1763+
.. availability:: Windows
1764+
17541765

17551766
.. function:: PYFUNCTYPE(restype, *argtypes)
17561767

@@ -1981,17 +1992,21 @@ Utility functions
19811992

19821993
.. function:: DllCanUnloadNow()
19831994

1984-
Windows only: This function is a hook which allows implementing in-process
1995+
This function is a hook which allows implementing in-process
19851996
COM servers with ctypes. It is called from the DllCanUnloadNow function that
19861997
the _ctypes extension dll exports.
19871998

1999+
.. availability:: Windows
2000+
19882001

19892002
.. function:: DllGetClassObject()
19902003

1991-
Windows only: This function is a hook which allows implementing in-process
2004+
This function is a hook which allows implementing in-process
19922005
COM servers with ctypes. It is called from the DllGetClassObject function
19932006
that the ``_ctypes`` extension dll exports.
19942007

2008+
.. availability:: Windows
2009+
19952010

19962011
.. function:: find_library(name)
19972012
:module: ctypes.util
@@ -2007,28 +2022,35 @@ Utility functions
20072022
.. function:: find_msvcrt()
20082023
:module: ctypes.util
20092024

2010-
Windows only: return the filename of the VC runtime library used by Python,
2025+
Returns the filename of the VC runtime library used by Python,
20112026
and by the extension modules. If the name of the library cannot be
20122027
determined, ``None`` is returned.
20132028

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

2033+
.. availability:: Windows
2034+
20182035

20192036
.. function:: FormatError([code])
20202037

2021-
Windows only: Returns a textual description of the error code *code*. If no
2038+
Returns a textual description of the error code *code*. If no
20222039
error code is specified, the last error code is used by calling the Windows
20232040
api function GetLastError.
20242041

2042+
.. availability:: Windows
2043+
20252044

20262045
.. function:: GetLastError()
20272046

2028-
Windows only: Returns the last error code set by Windows in the calling thread.
2047+
Returns the last error code set by Windows in the calling thread.
20292048
This function calls the Windows ``GetLastError()`` function directly,
20302049
it does not return the ctypes-private copy of the error code.
20312050

2051+
.. availability:: Windows
2052+
2053+
20322054
.. function:: get_errno()
20332055

20342056
Returns the current value of the ctypes-private copy of the system
@@ -2038,11 +2060,14 @@ Utility functions
20382060

20392061
.. function:: get_last_error()
20402062

2041-
Windows only: returns the current value of the ctypes-private copy of the system
2063+
Returns the current value of the ctypes-private copy of the system
20422064
:data:`!LastError` variable in the calling thread.
20432065

2066+
.. availability:: Windows
2067+
20442068
.. audit-event:: ctypes.get_last_error "" ctypes.get_last_error
20452069

2070+
20462071
.. function:: memmove(dst, src, count)
20472072

20482073
Same as the standard C memmove library function: copies *count* bytes from
@@ -2091,10 +2116,12 @@ Utility functions
20912116

20922117
.. function:: set_last_error(value)
20932118

2094-
Windows only: set the current value of the ctypes-private copy of the system
2119+
Sets the current value of the ctypes-private copy of the system
20952120
:data:`!LastError` variable in the calling thread to *value* and return the
20962121
previous value.
20972122

2123+
.. availability:: Windows
2124+
20982125
.. audit-event:: ctypes.set_last_error error ctypes.set_last_error
20992126

21002127

@@ -2115,12 +2142,14 @@ Utility functions
21152142

21162143
.. function:: WinError(code=None, descr=None)
21172144

2118-
Windows only: this function is probably the worst-named thing in ctypes. It
2145+
This function is probably the worst-named thing in ctypes. It
21192146
creates an instance of :exc:`OSError`. If *code* is not specified,
21202147
``GetLastError`` is called to determine the error code. If *descr* is not
21212148
specified, :func:`FormatError` is called to get a textual description of the
21222149
error.
21232150

2151+
.. availability:: Windows
2152+
21242153
.. versionchanged:: 3.3
21252154
An instance of :exc:`WindowsError` used to be created, which is now an
21262155
alias of :exc:`OSError`.
@@ -2484,9 +2513,11 @@ These are the fundamental ctypes data types:
24842513

24852514
.. class:: HRESULT
24862515

2487-
Windows only: Represents a :c:type:`!HRESULT` value, which contains success or
2516+
Represents a :c:type:`!HRESULT` value, which contains success or
24882517
error information for a function or method call.
24892518

2519+
.. availability:: Windows
2520+
24902521

24912522
.. class:: py_object
24922523

@@ -2755,7 +2786,7 @@ Exceptions
27552786

27562787
.. exception:: COMError(hresult, text, details)
27572788

2758-
Windows only: This exception is raised when a COM method call failed.
2789+
This exception is raised when a COM method call failed.
27592790

27602791
.. attribute:: hresult
27612792

@@ -2775,4 +2806,6 @@ Exceptions
27752806
identifier. *progid* is the ``ProgID`` of the interface that defined the
27762807
error.
27772808

2809+
.. availability:: Windows
2810+
27782811
.. versionadded:: next

0 commit comments

Comments
 (0)