Support buggy callers of PyString_GET_SIZE
In CPython, PyString_GET_SIZE and PyUnicode_GET_SIZE happen to have the same implementation, so it is ok for callers to be wrong about which one they call. For us, previous to this commit, PyString_GET_SIZE would call PyString_Size, which has different behavior than PyString_GET_SIZE for non-strings. For unicode objects it means that we would return the size of the encoded representation of the string rather than the number of unicode characters. It also means that PyString_GET_SIZE can fail for us and return -1, which it never can for CPython, so callers get away with not checking the return value.
Showing
Please register or sign in to comment