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

Skip to content

Commit d88d983

Browse files
author
Victor Stinner
committed
Fix PyUnicode_AsWideCharString() doc: size doesn't contain the null character
Fix also spelling of the null character.
1 parent a1bea6e commit d88d983

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Include/unicodeobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
595595

596596
/* Convert the Unicode object to a wide character string. The output string
597597
always ends with a nul character. If size is not NULL, write the number of
598-
wide characters (including the nul character) into *size.
598+
wide characters (excluding the null character) into *size.
599599
600600
Returns a buffer allocated by PyMem_Alloc() (use PyMem_Free() to free it)
601601
on success. On error, returns NULL, *size is undefined and raises a

Objects/unicodeobject.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,12 +1187,12 @@ PyUnicode_FromFormat(const char *format, ...)
11871187
/* Helper function for PyUnicode_AsWideChar() and PyUnicode_AsWideCharString():
11881188
convert a Unicode object to a wide character string.
11891189
1190-
- If w is NULL: return the number of wide characters (including the nul
1190+
- If w is NULL: return the number of wide characters (including the null
11911191
character) required to convert the unicode object. Ignore size argument.
11921192
1193-
- Otherwise: return the number of wide characters (excluding the nul
1193+
- Otherwise: return the number of wide characters (excluding the null
11941194
character) written into w. Write at most size wide characters (including
1195-
the nul character). */
1195+
the null character). */
11961196
static Py_ssize_t
11971197
unicode_aswidechar(PyUnicodeObject *unicode,
11981198
wchar_t *w,
@@ -1240,7 +1240,7 @@ unicode_aswidechar(PyUnicodeObject *unicode,
12401240
return w - worig;
12411241
}
12421242
else {
1243-
nchar = 1; /* nul character at the end */
1243+
nchar = 1; /* null character at the end */
12441244
while (u != uend) {
12451245
if (0xD800 <= u[0] && u[0] <= 0xDBFF
12461246
&& 0xDC00 <= u[1] && u[1] <= 0xDFFF)
@@ -1278,7 +1278,7 @@ unicode_aswidechar(PyUnicodeObject *unicode,
12781278
return w - worig;
12791279
}
12801280
else {
1281-
nchar = 1; /* nul character */
1281+
nchar = 1; /* null character */
12821282
while (u != uend) {
12831283
if (*u > 0xffff)
12841284
nchar += 2;

0 commit comments

Comments
 (0)