Skip to content

Commit 81a926b

Browse files
shreyanavigyaniritkatrielerlend-aasland
authored
pythongh-87969: Align docs and docstrings with implementation for ctypes' [w]string_at() (python#25384)
The implementation uses 'ptr' for the name of the first parameter of ctypes.string_at() and ctypes.wstring_at(). Align docs and docstrings with the naming used in the implementation. Co-authored-by: Irit Katriel <[email protected]> Co-authored-by: Erlend E. Aasland <[email protected]>
1 parent 340a02b commit 81a926b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Doc/library/ctypes.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,13 +2077,13 @@ Utility functions
20772077
Does the same as the C ``sizeof`` operator.
20782078

20792079

2080-
.. function:: string_at(address, size=-1)
2080+
.. function:: string_at(ptr, size=-1)
20812081

2082-
This function returns the C string starting at memory address *address* as a bytes
2083-
object. If size is specified, it is used as size, otherwise the string is assumed
2082+
Return the byte string at *void \*ptr*.
2083+
If *size* is specified, it is used as size, otherwise the string is assumed
20842084
to be zero-terminated.
20852085

2086-
.. audit-event:: ctypes.string_at address,size ctypes.string_at
2086+
.. audit-event:: ctypes.string_at ptr,size ctypes.string_at
20872087

20882088

20892089
.. function:: WinError(code=None, descr=None)
@@ -2099,14 +2099,14 @@ Utility functions
20992099
alias of :exc:`OSError`.
21002100

21012101

2102-
.. function:: wstring_at(address, size=-1)
2102+
.. function:: wstring_at(ptr, size=-1)
21032103

2104-
This function returns the wide character string starting at memory address
2105-
*address* as a string. If *size* is specified, it is used as the number of
2104+
Return the wide-character string at *void \*ptr*.
2105+
If *size* is specified, it is used as the number of
21062106
characters of the string, otherwise the string is assumed to be
21072107
zero-terminated.
21082108

2109-
.. audit-event:: ctypes.wstring_at address,size ctypes.wstring_at
2109+
.. audit-event:: ctypes.wstring_at ptr,size ctypes.wstring_at
21102110

21112111

21122112
.. _ctypes-data-types:

Lib/ctypes/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,9 @@ def cast(obj, typ):
534534

535535
_string_at = PYFUNCTYPE(py_object, c_void_p, c_int)(_string_at_addr)
536536
def string_at(ptr, size=-1):
537-
"""string_at(addr[, size]) -> string
537+
"""string_at(ptr[, size]) -> string
538538
539-
Return the string at addr."""
539+
Return the byte string at void *ptr."""
540540
return _string_at(ptr, size)
541541

542542
try:
@@ -546,9 +546,9 @@ def string_at(ptr, size=-1):
546546
else:
547547
_wstring_at = PYFUNCTYPE(py_object, c_void_p, c_int)(_wstring_at_addr)
548548
def wstring_at(ptr, size=-1):
549-
"""wstring_at(addr[, size]) -> string
549+
"""wstring_at(ptr[, size]) -> string
550550
551-
Return the string at addr."""
551+
Return the wide-character string at void *ptr."""
552552
return _wstring_at(ptr, size)
553553

554554

0 commit comments

Comments
 (0)