Repository navigation
Conversation
Documentation build overview
|
vstinner
left a comment
There was a problem hiding this comment.
It's a great idea to moving these functions to a dedicated function and write more details on conditions when using these functions is safe!
|
|
||
| - must not be hashed, | ||
| - must not be :c:func:`converted to UTF-8 <PyUnicode_AsUTF8AndSize>`, | ||
| or another non-"canonical" representation, |
There was a problem hiding this comment.
Currently, _PyUnicode_IsModifiable() returns 1 even if _PyUnicode_UTF8() is not NULL (for non-ASCII strings). Maybe it would be worth it return 0 in this case.
Note: For compact ASCII strings, _PyUnicode_UTF8() is always non-NULL.
There was a problem hiding this comment.
Yeah. If you modify the string after the UTF-8 representation is cached, it'll get out of sync.
For compact ASCII strings, _PyUnicode_UTF8() has undefined behaviour. Maybe it wants an assert.
I filed #159033
encukou
left a comment
There was a problem hiding this comment.
The details on conditions are just moved from the PyUnicode_New docs :)
|
|
||
| - must not be hashed, | ||
| - must not be :c:func:`converted to UTF-8 <PyUnicode_AsUTF8AndSize>`, | ||
| or another non-"canonical" representation, |
There was a problem hiding this comment.
Yeah. If you modify the string after the UTF-8 representation is cached, it'll get out of sync.
For compact ASCII strings, _PyUnicode_UTF8() has undefined behaviour. Maybe it wants an assert.
I filed #159033
ZeroIntensity
left a comment
There was a problem hiding this comment.
I'm a little late to the party, but this seems worthwhile!
This moves documentation of the naughty functions to a new own section under the existing "Deprecated API", to de-emphasize them, and provide a common introduction (with links from each function).