Skip to content

Commit caad904

Browse files
authored
[3.12] gh-127082: Replace "Windows only" with the availability: Windows in ctypes doc (GH-127099) (#127145)
(cherry picked from commit 3c770e3)
1 parent c470e82 commit caad904

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

Doc/library/ctypes.rst

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,13 +1390,15 @@ way is to instantiate one of the following classes:
13901390

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

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

1400+
.. availability:: Windows
1401+
14001402
.. versionchanged:: 3.3
14011403
:exc:`WindowsError` used to be raised,
14021404
which is now an alias of :exc:`OSError`.
@@ -1408,14 +1410,17 @@ way is to instantiate one of the following classes:
14081410

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

1411-
Windows only: Instances of this class represent loaded shared libraries,
1413+
Instances of this class represent loaded shared libraries,
14121414
functions in these libraries use the ``stdcall`` calling convention, and are
14131415
assumed to return :c:expr:`int` by default.
14141416

1417+
.. availability:: Windows
1418+
14151419
.. versionchanged:: 3.12
14161420

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

1423+
14191424
The Python :term:`global interpreter lock` is released before calling any
14201425
function exported by these libraries, and reacquired afterwards.
14211426

@@ -1551,13 +1556,17 @@ These prefabricated library loaders are available:
15511556
.. data:: windll
15521557
:noindex:
15531558

1554-
Windows only: Creates :class:`WinDLL` instances.
1559+
Creates :class:`WinDLL` instances.
1560+
1561+
.. availability:: Windows
15551562

15561563

15571564
.. data:: oledll
15581565
:noindex:
15591566

1560-
Windows only: Creates :class:`OleDLL` instances.
1567+
Creates :class:`OleDLL` instances.
1568+
1569+
.. availability:: Windows
15611570

15621571

15631572
.. data:: pydll
@@ -1729,11 +1738,13 @@ See :ref:`ctypes-callback-functions` for examples.
17291738

17301739
.. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
17311740

1732-
Windows only: The returned function prototype creates functions that use the
1741+
The returned function prototype creates functions that use the
17331742
``stdcall`` calling convention. The function will
17341743
release the GIL during the call. *use_errno* and *use_last_error* have the
17351744
same meaning as above.
17361745

1746+
.. availability:: Windows
1747+
17371748

17381749
.. function:: PYFUNCTYPE(restype, *argtypes)
17391750

@@ -1959,17 +1970,21 @@ Utility functions
19591970

19601971
.. function:: DllCanUnloadNow()
19611972

1962-
Windows only: This function is a hook which allows implementing in-process
1973+
This function is a hook which allows implementing in-process
19631974
COM servers with ctypes. It is called from the DllCanUnloadNow function that
19641975
the _ctypes extension dll exports.
19651976

1977+
.. availability:: Windows
1978+
19661979

19671980
.. function:: DllGetClassObject()
19681981

1969-
Windows only: This function is a hook which allows implementing in-process
1982+
This function is a hook which allows implementing in-process
19701983
COM servers with ctypes. It is called from the DllGetClassObject function
19711984
that the ``_ctypes`` extension dll exports.
19721985

1986+
.. availability:: Windows
1987+
19731988

19741989
.. function:: find_library(name)
19751990
:module: ctypes.util
@@ -1985,28 +2000,35 @@ Utility functions
19852000
.. function:: find_msvcrt()
19862001
:module: ctypes.util
19872002

1988-
Windows only: return the filename of the VC runtime library used by Python,
2003+
Returns the filename of the VC runtime library used by Python,
19892004
and by the extension modules. If the name of the library cannot be
19902005
determined, ``None`` is returned.
19912006

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

2011+
.. availability:: Windows
2012+
19962013

19972014
.. function:: FormatError([code])
19982015

1999-
Windows only: Returns a textual description of the error code *code*. If no
2016+
Returns a textual description of the error code *code*. If no
20002017
error code is specified, the last error code is used by calling the Windows
20012018
api function GetLastError.
20022019

2020+
.. availability:: Windows
2021+
20032022

20042023
.. function:: GetLastError()
20052024

2006-
Windows only: Returns the last error code set by Windows in the calling thread.
2025+
Returns the last error code set by Windows in the calling thread.
20072026
This function calls the Windows ``GetLastError()`` function directly,
20082027
it does not return the ctypes-private copy of the error code.
20092028

2029+
.. availability:: Windows
2030+
2031+
20102032
.. function:: get_errno()
20112033

20122034
Returns the current value of the ctypes-private copy of the system
@@ -2016,11 +2038,14 @@ Utility functions
20162038

20172039
.. function:: get_last_error()
20182040

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

2044+
.. availability:: Windows
2045+
20222046
.. audit-event:: ctypes.get_last_error "" ctypes.get_last_error
20232047

2048+
20242049
.. function:: memmove(dst, src, count)
20252050

20262051
Same as the standard C memmove library function: copies *count* bytes from
@@ -2069,10 +2094,12 @@ Utility functions
20692094

20702095
.. function:: set_last_error(value)
20712096

2072-
Windows only: set the current value of the ctypes-private copy of the system
2097+
Sets the current value of the ctypes-private copy of the system
20732098
:data:`!LastError` variable in the calling thread to *value* and return the
20742099
previous value.
20752100

2101+
.. availability:: Windows
2102+
20762103
.. audit-event:: ctypes.set_last_error error ctypes.set_last_error
20772104

20782105

@@ -2093,12 +2120,14 @@ Utility functions
20932120

20942121
.. function:: WinError(code=None, descr=None)
20952122

2096-
Windows only: this function is probably the worst-named thing in ctypes. It
2123+
This function is probably the worst-named thing in ctypes. It
20972124
creates an instance of :exc:`OSError`. If *code* is not specified,
20982125
``GetLastError`` is called to determine the error code. If *descr* is not
20992126
specified, :func:`FormatError` is called to get a textual description of the
21002127
error.
21012128

2129+
.. availability:: Windows
2130+
21022131
.. versionchanged:: 3.3
21032132
An instance of :exc:`WindowsError` used to be created, which is now an
21042133
alias of :exc:`OSError`.
@@ -2438,9 +2467,11 @@ These are the fundamental ctypes data types:
24382467

24392468
.. class:: HRESULT
24402469

2441-
Windows only: Represents a :c:type:`!HRESULT` value, which contains success or
2470+
Represents a :c:type:`!HRESULT` value, which contains success or
24422471
error information for a function or method call.
24432472

2473+
.. availability:: Windows
2474+
24442475

24452476
.. class:: py_object
24462477

0 commit comments

Comments
 (0)