@@ -59,8 +59,8 @@ Unless otherwise stated, buffers are not NUL-terminated.
5959 Convert a Unicode object to a C pointer to a character string.
6060 A pointer to an existing string is stored in the character pointer
6161 variable whose address you pass. The C string is NUL-terminated.
62- The Python string must not contain embedded NUL bytes ; if it does,
63- a :exc: `TypeError ` exception is raised. Unicode objects are converted
62+ The Python string must not contain embedded null characters ; if it does,
63+ a :exc: `ValueError ` exception is raised. Unicode objects are converted
6464 to C strings using ``'utf-8' `` encoding. If this conversion fails, a
6565 :exc: `UnicodeError ` is raised.
6666
@@ -71,6 +71,10 @@ Unless otherwise stated, buffers are not NUL-terminated.
7171 preferable to use the ``O& `` format with :c:func: `PyUnicode_FSConverter `
7272 as *converter *.
7373
74+ .. versionchanged :: 3.5
75+ Previously, :exc: `TypeError ` was raised when embedded null characters
76+ were encountered in the Python string.
77+
7478``s* `` (:class: `str ` or :term: `bytes-like object `) [Py_buffer]
7579 This format accepts Unicode objects as well as bytes-like objects.
7680 It fills a :c:type: `Py_buffer ` structure provided by the caller.
@@ -99,9 +103,13 @@ Unless otherwise stated, buffers are not NUL-terminated.
99103``y `` (read-only :term: `bytes-like object `) [const char \* ]
100104 This format converts a bytes-like object to a C pointer to a character
101105 string; it does not accept Unicode objects. The bytes buffer must not
102- contain embedded NUL bytes; if it does, a :exc: `TypeError `
106+ contain embedded null bytes; if it does, a :exc: `ValueError `
103107 exception is raised.
104108
109+ .. versionchanged :: 3.5
110+ Previously, :exc: `TypeError ` was raised when embedded null bytes were
111+ encountered in the bytes buffer.
112+
105113``y* `` (:term: `bytes-like object `) [Py_buffer]
106114 This variant on ``s* `` doesn't accept Unicode objects, only
107115 bytes-like objects. **This is the recommended way to accept
@@ -127,14 +135,18 @@ Unless otherwise stated, buffers are not NUL-terminated.
127135 pointer variable, which will be filled with the pointer to an existing
128136 Unicode buffer. Please note that the width of a :c:type: `Py_UNICODE `
129137 character depends on compilation options (it is either 16 or 32 bits).
130- The Python string must not contain embedded NUL characters; if it does,
131- a :exc: `TypeError ` exception is raised.
138+ The Python string must not contain embedded null characters; if it does,
139+ a :exc: `ValueError ` exception is raised.
132140
133141 .. note ::
134142 Since ``u `` doesn't give you back the length of the string, and it
135143 may contain embedded NUL characters, it is recommended to use ``u# ``
136144 or ``U `` instead.
137145
146+ .. versionchanged :: 3.5
147+ Previously, :exc: `TypeError ` was raised when embedded null characters
148+ were encountered in the Python string.
149+
138150``u# `` (:class: `str `) [Py_UNICODE \* , int]
139151 This variant on ``u `` stores into two C variables, the first one a pointer to a
140152 Unicode data buffer, the second one its length.
0 commit comments