Message281439
PyUnicode_AsUTF8AndSize() and PyUnicode_AsUTF8() return a reference to cached readonly UTF-8 representation of a string. Changing the content of the UTF-8 representation is an error. Proposed patch makes these functions returning "const char *" rather of "char *" to force this restriction.
This is backward-incompatible change. Since PyUnicode_AsUTF8AndSize() and PyUnicode_AsUTF8() can return an error, it is more likely that the result is saved in a local variable rather than passing to other function. If the type of this variable is "char *" rather than "const char *", this would cause a compiler error. The fix is simple -- just add the const qualifier to the local variable declaration (more preferable) or cast the result of PyUnicode_AsUTF8AndSize() or PyUnicode_AsUTF8() to "char *".
Both functions are not in stable API. |
|
Date |
User |
Action |
Args |
2016-11-22 07:55:24 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, ncoghlan |
2016-11-22 07:55:24 | serhiy.storchaka | set | messageid: <1479801324.65.0.962202188144.issue28769@psf.upfronthosting.co.za> |
2016-11-22 07:55:24 | serhiy.storchaka | link | issue28769 messages |
2016-11-22 07:55:24 | serhiy.storchaka | create | |
|