bpo-40130: _PyUnicode_AsKind() should not be exported.#19265
Conversation
Make it a static function, and pass known attributes (kind, data, length) instead of the PyUnicode object.
vstinner
left a comment
There was a problem hiding this comment.
LGTM. It's fine to remove private functions whenever we want, especially before a release.
First, I wasn't sure if it's a good idea to require the (kind, data, len) triplet rather than PyObject*, but after I read the issue, I think that it's ok.
| return; | ||
| } | ||
| else { | ||
| else if (kind == PyUnicode_4BYTE_KIND) { |
There was a problem hiding this comment.
Maybe a switch/case would be more appropriate.
There was a problem hiding this comment.
Maybe. I left a chain of ifs because I am sure that in this case the compiler would generate the optimal code for PyUnicode_1BYTE_KIND, and I am not so sure about this in the case of switch/case. It may be a matter of other issue, I do not want to introduce regression.
There was a problem hiding this comment.
It was just a remark. You can leave the code as it is, I already approved your PR.
| Py_UCS1, Py_UCS2, | ||
| PyUnicode_1BYTE_DATA(s), | ||
| PyUnicode_1BYTE_DATA(s) + len, | ||
| (Py_UCS1 *)data, |
There was a problem hiding this comment.
it should be const Py_UCS1*, no?
Make it a static function, and pass known attributes (kind, data, length) instead of the PyUnicode object.
https://bugs.python.org/issue40130