summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/unicode.rst16
-rw-r--r--Doc/whatsnew/3.7.rst4
2 files changed, 15 insertions, 5 deletions
diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst
index 84059e4..45aff1b 100644
--- a/Doc/c-api/unicode.rst
+++ b/Doc/c-api/unicode.rst
@@ -934,16 +934,22 @@ wchar_t Support
Convert the Unicode object to a wide character string. The output string
always ends with a null character. If *size* is not *NULL*, write the number
of wide characters (excluding the trailing null termination character) into
- *\*size*.
+ *\*size*. Note that the resulting :c:type:`wchar_t` string might contain
+ null characters, which would cause the string to be truncated when used with
+ most C functions. If *size* is *NULL* and the :c:type:`wchar_t*` string
+ contains null characters a :exc:`ValueError` is raised.
Returns a buffer allocated by :c:func:`PyMem_Alloc` (use
- :c:func:`PyMem_Free` to free it) on success. On error, returns *NULL*,
- *\*size* is undefined and raises a :exc:`MemoryError`. Note that the
- resulting :c:type:`wchar_t` string might contain null characters, which
- would cause the string to be truncated when used with most C functions.
+ :c:func:`PyMem_Free` to free it) on success. On error, returns *NULL*
+ and *\*size* is undefined. Raises a :exc:`MemoryError` if memory allocation
+ is failed.
.. versionadded:: 3.2
+ .. versionchanged:: 3.7
+ Raises a :exc:`ValueError` if *size* is *NULL* and the :c:type:`wchar_t*`
+ string contains null characters.
+
.. _builtincodecs:
diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst
index 927ae5b..e34268e 100644
--- a/Doc/whatsnew/3.7.rst
+++ b/Doc/whatsnew/3.7.rst
@@ -360,6 +360,10 @@ Changes in the C API
:c:type:`unsigned long`.
(Contributed by Serhiy Storchaka in :issue:`6532`.)
+- :c:func:`PyUnicode_AsWideCharString` now raises a :exc:`ValueError` if the
+ second argument is *NULL* and the :c:type:`wchar_t*` string contains null
+ characters. (Contributed by Serhiy Storchaka in :issue:`30708`.)
+
Removed
=======