-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement
Description
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
Lines 594 to 596 in a85eeb9
/* result is guaranteed to be ready, as it is compact. */ | |
kind = PyUnicode_KIND(result); | |
data = PyUnicode_DATA(result); |
Lines 655 to 661 in a85eeb9
result = nfd_nfkd(self, input, k); | |
if (!result) | |
return NULL; | |
/* result will be "ready". */ | |
kind = PyUnicode_KIND(result); | |
data = PyUnicode_DATA(result); | |
len = PyUnicode_GET_LENGTH(result); |
_io/textio.c
Lines 357 to 363 in a85eeb9
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++; |
Lines 1821 to 1824 in a85eeb9
/* decoded_chars is guaranteed to be "ready". */ | |
avail = (PyUnicode_GET_LENGTH(self->decoded_chars) | |
- self->decoded_chars_used); | |
Parser
files
Lines 311 to 315 in a85eeb9
/* Verify that the identifier follows PEP 3131. | |
All identifier strings are guaranteed to be "ready" unicode objects. | |
*/ | |
static int | |
verify_identifier(struct tok_state *tok) |
Lines 505 to 513 in a85eeb9
PyObject * | |
_PyPegen_new_identifier(Parser *p, const char *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
Lines 252 to 259 in a85eeb9
if (!PyUnicode_IS_READY(filename)) { | |
/* Don't make a Unicode string ready to avoid reentrant calls | |
to tracemalloc_alloc() or tracemalloc_realloc() */ | |
#ifdef TRACE_DEBUG | |
tracemalloc_error("filename is not a ready unicode string"); | |
#endif | |
return; | |
} |
This one seems to be dead code (cc @vstinner)
Linked PRs
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement