Function PyUnicode_GET_LENGTH' doc may need some improvement

I spent some time reading the code and I am 80% confident that the value returned by this function does not include the terminating null character. I think we should explain clearly this in the documentation.
url

For example ,we have codes

 if (PyUnicode_FindChar(key, '\0', 0, PyUnicode_GET_LENGTH(key), 1) != -1 ||
            PyUnicode_FindChar(value, '\0', 0, PyUnicode_GET_LENGTH(value), 1) != -1)
        {
            PyErr_SetString(PyExc_ValueError, "embedded null character");
            goto error;
        }

You are assuming C string semantics it seems.

python strings are defined by a length not special terminator values.

1 Like

That is enforcing a Windows API requirement and does not support you assumption that \0 is a terminator for python strings.

1 Like

Thanks a lot!