summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-04-19 11:23:26 (GMT)
committerGitHub <noreply@github.com>2024-04-19 11:23:26 (GMT)
commit26c659ecbd8c2b9b00c078d902d20396ce583fda (patch)
treec0f02b7aa7eb40d12a031e1272c814b804be719b
parentf278b8fefca7ad5d0e95c4b5df39807a80cf821a (diff)
downloadcpython-26c659ecbd8c2b9b00c078d902d20396ce583fda.zip
cpython-26c659ecbd8c2b9b00c078d902d20396ce583fda.tar.gz
cpython-26c659ecbd8c2b9b00c078d902d20396ce583fda.tar.bz2
[3.12] gh-87969: Align docs and docstrings with implementation for ctypes' [w]string_at() (GH-25384) (GH-118046)
gh-87969: Align docs and docstrings with implementation for ctypes' [w]string_at() (GH-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. (cherry picked from commit 81a926bd20a8c66646e51b66ef1cfb309b73ebe7) Co-authored-by: Shreyan Avigyan <shreyan.avigyan@gmail.com> Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
-rw-r--r--Doc/library/ctypes.rst16
-rw-r--r--Lib/ctypes/__init__.py8
2 files changed, 12 insertions, 12 deletions
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index 9482497..e64e2f6 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -2072,13 +2072,13 @@ Utility functions
Does the same as the C ``sizeof`` operator.
-.. function:: string_at(address, size=-1)
+.. function:: string_at(ptr, size=-1)
- This function returns the C string starting at memory address *address* as a bytes
- object. If size is specified, it is used as size, otherwise the string is assumed
+ Return the byte string at *void \*ptr*.
+ If *size* is specified, it is used as size, otherwise the string is assumed
to be zero-terminated.
- .. audit-event:: ctypes.string_at address,size ctypes.string_at
+ .. audit-event:: ctypes.string_at ptr,size ctypes.string_at
.. function:: WinError(code=None, descr=None)
@@ -2094,14 +2094,14 @@ Utility functions
alias of :exc:`OSError`.
-.. function:: wstring_at(address, size=-1)
+.. function:: wstring_at(ptr, size=-1)
- This function returns the wide character string starting at memory address
- *address* as a string. If *size* is specified, it is used as the number of
+ Return the wide-character string at *void \*ptr*.
+ If *size* is specified, it is used as the number of
characters of the string, otherwise the string is assumed to be
zero-terminated.
- .. audit-event:: ctypes.wstring_at address,size ctypes.wstring_at
+ .. audit-event:: ctypes.wstring_at ptr,size ctypes.wstring_at
.. _ctypes-data-types:
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index 95353ba..6cedee7 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -519,9 +519,9 @@ def cast(obj, typ):
_string_at = PYFUNCTYPE(py_object, c_void_p, c_int)(_string_at_addr)
def string_at(ptr, size=-1):
- """string_at(addr[, size]) -> string
+ """string_at(ptr[, size]) -> string
- Return the string at addr."""
+ Return the byte string at void *ptr."""
return _string_at(ptr, size)
try:
@@ -531,9 +531,9 @@ except ImportError:
else:
_wstring_at = PYFUNCTYPE(py_object, c_void_p, c_int)(_wstring_at_addr)
def wstring_at(ptr, size=-1):
- """wstring_at(addr[, size]) -> string
+ """wstring_at(ptr[, size]) -> string
- Return the string at addr."""
+ Return the wide-character string at void *ptr."""
return _wstring_at(ptr, size)