Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c9e7ef7

Browse files
committed
- Issue #13840: Fix ctypes.create_string_buffer exception message and docs.
2 parents 7f2b576 + 65992c1 commit c9e7ef7

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

Doc/library/ctypes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,8 +1823,6 @@ Utility functions
18231823
termination character. An integer can be passed as second argument which allows
18241824
to specify the size of the array if the length of the bytes should not be used.
18251825

1826-
If the first parameter is a string, it is converted into a bytes object
1827-
according to ctypes conversion rules.
18281826

18291827

18301828
.. function:: create_unicode_buffer(init_or_size, size=None)
@@ -1841,8 +1839,6 @@ Utility functions
18411839
allows to specify the size of the array if the length of the string should not
18421840
be used.
18431841

1844-
If the first parameter is a bytes object, it is converted into an unicode string
1845-
according to ctypes conversion rules.
18461842

18471843

18481844
.. function:: DllCanUnloadNow()

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,9 @@ Tools/Demos
18371837
Extension Modules
18381838
-----------------
18391839

1840+
- Issue #13840: The error message produced by ctypes.create_string_buffer
1841+
when given a Unicode string has been fixed.
1842+
18401843
- Issue #9975: socket: Fix incorrect use of flowinfo and scope_id. Patch by
18411844
Vilmos Nebehaj.
18421845

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ CharArray_set_value(CDataObject *self, PyObject *value)
10961096

10971097
if (!PyBytes_Check(value)) {
10981098
PyErr_Format(PyExc_TypeError,
1099-
"str/bytes expected instead of %s instance",
1099+
"bytes expected instead of %s instance",
11001100
Py_TYPE(value)->tp_name);
11011101
return -1;
11021102
} else

0 commit comments

Comments
 (0)