Skip to content

Commit 3c643a4

Browse files
Remove references about unicode's readiness from comments
1 parent d0eb01c commit 3c643a4

File tree

7 files changed

+8
-14
lines changed

7 files changed

+8
-14
lines changed

Include/cpython/unicodeobject.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,22 +212,21 @@ static inline unsigned int PyUnicode_IS_READY(PyObject* Py_UNUSED(op)) {
212212
#define PyUnicode_IS_READY(op) PyUnicode_IS_READY(_PyObject_CAST(op))
213213

214214
/* Return true if the string contains only ASCII characters, or 0 if not. The
215-
string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
216-
ready. */
215+
string may be compact (PyUnicode_IS_COMPACT_ASCII) or not. */
217216
static inline unsigned int PyUnicode_IS_ASCII(PyObject *op) {
218217
return _PyASCIIObject_CAST(op)->state.ascii;
219218
}
220219
#define PyUnicode_IS_ASCII(op) PyUnicode_IS_ASCII(_PyObject_CAST(op))
221220

222221
/* Return true if the string is compact or 0 if not.
223-
No type checks or Ready calls are performed. */
222+
No type checks are performed. */
224223
static inline unsigned int PyUnicode_IS_COMPACT(PyObject *op) {
225224
return _PyASCIIObject_CAST(op)->state.compact;
226225
}
227226
#define PyUnicode_IS_COMPACT(op) PyUnicode_IS_COMPACT(_PyObject_CAST(op))
228227

229228
/* Return true if the string is a compact ASCII string (use PyASCIIObject
230-
structure), or 0 if not. No type checks or Ready calls are performed. */
229+
structure), or 0 if not. No type checks are performed. */
231230
static inline int PyUnicode_IS_COMPACT_ASCII(PyObject *op) {
232231
return (_PyASCIIObject_CAST(op)->state.ascii && PyUnicode_IS_COMPACT(op));
233232
}
@@ -319,7 +318,7 @@ static inline void PyUnicode_WRITE(int kind, void *data,
319318
(index), _Py_STATIC_CAST(Py_UCS4, value))
320319

321320
/* Read a code point from the string's canonical representation. No checks
322-
or ready calls are performed. */
321+
are performed. */
323322
static inline Py_UCS4 PyUnicode_READ(int kind,
324323
const void *data, Py_ssize_t index)
325324
{

Include/internal/pycore_traceback.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ extern const char* _Py_DumpTracebackThreads(
6666
/* Write a Unicode object into the file descriptor fd. Encode the string to
6767
ASCII using the backslashreplace error handler.
6868
69-
Do nothing if text is not a Unicode object. The function accepts Unicode
70-
string which is not ready (PyUnicode_WCHAR_KIND).
69+
Do nothing if text is not a Unicode object.
7170
7271
This function is signal safe. */
7372
extern void _Py_DumpASCII(int fd, PyObject *text);

Modules/_io/textio.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ _PyIncrementalNewlineDecoder_decode(PyObject *myself,
358358
out = PyUnicode_DATA(modified);
359359
PyUnicode_WRITE(kind, out, 0, '\r');
360360
memcpy(out + kind, PyUnicode_DATA(output), kind * output_len);
361-
Py_SETREF(output, modified); /* output remains ready */
361+
Py_SETREF(output, modified);
362362
self->pendingcr = 0;
363363
output_len++;
364364
}
@@ -1818,7 +1818,6 @@ textiowrapper_get_decoded_chars(textio *self, Py_ssize_t n)
18181818
if (self->decoded_chars == NULL)
18191819
return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
18201820

1821-
/* decoded_chars is guaranteed to be "ready". */
18221821
avail = (PyUnicode_GET_LENGTH(self->decoded_chars)
18231822
- self->decoded_chars_used);
18241823

Modules/unicodedata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ nfd_nfkd(PyObject *self, PyObject *input, int k)
591591
PyMem_Free(output);
592592
if (!result)
593593
return NULL;
594-
/* result is guaranteed to be ready, as it is compact. */
594+
595595
kind = PyUnicode_KIND(result);
596596
data = PyUnicode_DATA(result);
597597

@@ -655,7 +655,7 @@ nfc_nfkc(PyObject *self, PyObject *input, int k)
655655
result = nfd_nfkd(self, input, k);
656656
if (!result)
657657
return NULL;
658-
/* result will be "ready". */
658+
659659
kind = PyUnicode_KIND(result);
660660
data = PyUnicode_DATA(result);
661661
len = PyUnicode_GET_LENGTH(result);

Parser/lexer/lexer.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ verify_end_of_number(struct tok_state *tok, int c, const char *kind) {
309309
}
310310

311311
/* Verify that the identifier follows PEP 3131.
312-
All identifier strings are guaranteed to be "ready" unicode objects.
313312
*/
314313
static int
315314
verify_identifier(struct tok_state *tok)

Parser/pegen.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ _PyPegen_new_identifier(Parser *p, const char *n)
509509
if (!id) {
510510
goto error;
511511
}
512-
/* PyUnicode_DecodeUTF8 should always return a ready string. */
513512
assert(PyUnicode_IS_READY(id));
514513
/* Check whether there are non-ASCII characters in the
515514
identifier; if so, normalize to NFKC. */

Python/codecs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,6 @@ _PyCodec_SurrogatePassUnicodeEncodeError(PyObject *exc)
12561256

12571257
unsigned char *outp = (unsigned char *)PyBytes_AsString(res);
12581258
for (Py_ssize_t i = start; i < end; i++) {
1259-
/* object is guaranteed to be "ready" */
12601259
Py_UCS4 ch = PyUnicode_READ_CHAR(obj, i);
12611260
if (!Py_UNICODE_IS_SURROGATE(ch)) {
12621261
/* Not a surrogate, fail with original exception */

0 commit comments

Comments
 (0)