We have some code referrencing readiness of Unicode objects but this property is deprecated (see #129894 (comment)). Following @encukou's advice, we should address each module with a separate PR so that experts can review them separately.
unicodedata.c
| /* result is guaranteed to be ready, as it is compact. */ |
| kind=PyUnicode_KIND(result); |
| data=PyUnicode_DATA(result); |
| result=nfd_nfkd(self, input, k); |
| if (!result) |
| returnNULL; |
| /* result will be "ready". */ |
| kind=PyUnicode_KIND(result); |
| data=PyUnicode_DATA(result); |
| len=PyUnicode_GET_LENGTH(result); |
_io/textio.c
| kind=PyUnicode_KIND(modified); |
| out=PyUnicode_DATA(modified); |
| PyUnicode_WRITE(kind, out, 0, '\r'); |
| memcpy(out+kind, PyUnicode_DATA(output), kind*output_len); |
| Py_SETREF(output, modified); /* output remains ready */ |
| self->pendingcr=0; |
| output_len++; |
| /* decoded_chars is guaranteed to be "ready". */ |
| avail= (PyUnicode_GET_LENGTH(self->decoded_chars) |
| -self->decoded_chars_used); |
| |
Parser files
| /* Verify that the identifier follows PEP 3131. |
| All identifier strings are guaranteed to be "ready" unicode objects. |
| */ |
| staticint |
| verify_identifier(structtok_state*tok) |
| PyObject* |
| _PyPegen_new_identifier(Parser*p, constchar*n) |
| { |
| PyObject*id=PyUnicode_DecodeUTF8(n, (Py_ssize_t)strlen(n), NULL); |
| if (!id) { |
| goto error; |
| } |
| /* PyUnicode_DecodeUTF8 should always return a ready string. */ |
| assert(PyUnicode_IS_READY(id)); |
tracemalloc.c
| if (!PyUnicode_IS_READY(filename)) { |
| /* Don't make a Unicode string ready to avoid reentrant calls |
| to tracemalloc_alloc() or tracemalloc_realloc() */ |
| #ifdefTRACE_DEBUG |
| tracemalloc_error("filename is not a ready unicode string"); |
| #endif |
| return; |
| } |
This one seems to be dead code (cc @vstinner)
Linked PRs
We have some code referrencing readiness of Unicode objects but this property is deprecated (see #129894 (comment)). Following @encukou's advice, we should address each module with a separate PR so that experts can review them separately.
unicodedata.ccpython/Modules/unicodedata.c
Lines 594 to 596 in a85eeb9
cpython/Modules/unicodedata.c
Lines 655 to 661 in a85eeb9
_io/textio.ccpython/Modules/_io/textio.c
Lines 357 to 363 in a85eeb9
cpython/Modules/_io/textio.c
Lines 1821 to 1824 in a85eeb9
Parserfilescpython/Parser/lexer/lexer.c
Lines 311 to 315 in a85eeb9
cpython/Parser/pegen.c
Lines 505 to 513 in a85eeb9
tracemalloc.ccpython/Python/tracemalloc.c
Lines 252 to 259 in a85eeb9
This one seems to be dead code (cc @vstinner)
Linked PRs