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

Skip to content

Commit 65992c1

Browse files
committed
- Issue #13840: Fix ctypes.create_string_buffer exception message and docs.
1 parent eaac4f0 commit 65992c1

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
@@ -1815,8 +1815,6 @@ Utility functions
18151815
termination character. An integer can be passed as second argument which allows
18161816
to specify the size of the array if the length of the bytes should not be used.
18171817

1818-
If the first parameter is a string, it is converted into a bytes object
1819-
according to ctypes conversion rules.
18201818

18211819

18221820
.. function:: create_unicode_buffer(init_or_size, size=None)
@@ -1833,8 +1831,6 @@ Utility functions
18331831
allows to specify the size of the array if the length of the string should not
18341832
be used.
18351833

1836-
If the first parameter is a bytes object, it is converted into an unicode string
1837-
according to ctypes conversion rules.
18381834

18391835

18401836
.. function:: DllCanUnloadNow()

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ Tests
402402
Extension Modules
403403
-----------------
404404

405+
- Issue #13840: The error message produced by ctypes.create_string_buffer
406+
when given a Unicode string has been fixed.
407+
405408
- Issue #9975: socket: Fix incorrect use of flowinfo and scope_id. Patch by
406409
Vilmos Nebehaj.
407410

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)