]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-130790: Remove references about unicode's readiness from comments (#130801)
authorSergey Miryanov <sergey.miryanov@gmail.com>
Mon, 3 Mar 2025 19:18:09 +0000 (00:18 +0500)
committerGitHub <noreply@github.com>
Mon, 3 Mar 2025 19:18:09 +0000 (19:18 +0000)
Include/cpython/unicodeobject.h
Include/internal/pycore_traceback.h
Modules/_io/textio.c
Modules/unicodedata.c
Objects/typeobject.c
Objects/unicodeobject.c
Parser/lexer/lexer.c
Parser/pegen.c
Python/codecs.c
Python/formatter_unicode.c
Python/tracemalloc.c

index 463cbf24ce169243e1ac7772e8daf962cf43d7be..e8b04d158b0805958f2e8193bbba9d34228978d7 100644 (file)
@@ -212,22 +212,21 @@ static inline unsigned int PyUnicode_IS_READY(PyObject* Py_UNUSED(op)) {
 #define PyUnicode_IS_READY(op) PyUnicode_IS_READY(_PyObject_CAST(op))
 
 /* Return true if the string contains only ASCII characters, or 0 if not. The
-   string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
-   ready. */
+   string may be compact (PyUnicode_IS_COMPACT_ASCII) or not. */
 static inline unsigned int PyUnicode_IS_ASCII(PyObject *op) {
     return _PyASCIIObject_CAST(op)->state.ascii;
 }
 #define PyUnicode_IS_ASCII(op) PyUnicode_IS_ASCII(_PyObject_CAST(op))
 
 /* Return true if the string is compact or 0 if not.
-   No type checks or Ready calls are performed. */
+   No type checks are performed. */
 static inline unsigned int PyUnicode_IS_COMPACT(PyObject *op) {
     return _PyASCIIObject_CAST(op)->state.compact;
 }
 #define PyUnicode_IS_COMPACT(op) PyUnicode_IS_COMPACT(_PyObject_CAST(op))
 
 /* Return true if the string is a compact ASCII string (use PyASCIIObject
-   structure), or 0 if not.  No type checks or Ready calls are performed. */
+   structure), or 0 if not.  No type checks are performed. */
 static inline int PyUnicode_IS_COMPACT_ASCII(PyObject *op) {
     return (_PyASCIIObject_CAST(op)->state.ascii && PyUnicode_IS_COMPACT(op));
 }
@@ -319,7 +318,7 @@ static inline void PyUnicode_WRITE(int kind, void *data,
                     (index), _Py_STATIC_CAST(Py_UCS4, value))
 
 /* Read a code point from the string's canonical representation.  No checks
-   or ready calls are performed. */
+   are performed. */
 static inline Py_UCS4 PyUnicode_READ(int kind,
                                      const void *data, Py_ssize_t index)
 {
index 10922bff98bd4bc0060189833d05b59ac4dc649f..741108a957a35c2ce29ea96e7cde95469130d0e7 100644 (file)
@@ -66,8 +66,7 @@ extern const char* _Py_DumpTracebackThreads(
 /* Write a Unicode object into the file descriptor fd. Encode the string to
    ASCII using the backslashreplace error handler.
 
-   Do nothing if text is not a Unicode object. The function accepts Unicode
-   string which is not ready (PyUnicode_WCHAR_KIND).
+   Do nothing if text is not a Unicode object.
 
    This function is signal safe. */
 extern void _Py_DumpASCII(int fd, PyObject *text);
index 935aaab20a031f62bb3c98e97e85c905ea16c794..071a06ffbf73347155b7d64b789bbceec22de568 100644 (file)
@@ -358,7 +358,7 @@ _PyIncrementalNewlineDecoder_decode(PyObject *myself,
         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 */
+        Py_SETREF(output, modified);
         self->pendingcr = 0;
         output_len++;
     }
@@ -1818,7 +1818,6 @@ textiowrapper_get_decoded_chars(textio *self, Py_ssize_t n)
     if (self->decoded_chars == NULL)
         return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
 
-    /* decoded_chars is guaranteed to be "ready". */
     avail = (PyUnicode_GET_LENGTH(self->decoded_chars)
              - self->decoded_chars_used);
 
index f1ff7bd3eba232d4ebe481e3130cc14517f1a1d0..ef8cf3d0d274592c5991f05f807bdc77b29402fe 100644 (file)
@@ -591,7 +591,7 @@ nfd_nfkd(PyObject *self, PyObject *input, int k)
     PyMem_Free(output);
     if (!result)
         return NULL;
-    /* result is guaranteed to be ready, as it is compact. */
+
     kind = PyUnicode_KIND(result);
     data = PyUnicode_DATA(result);
 
@@ -655,7 +655,7 @@ nfc_nfkc(PyObject *self, PyObject *input, int k)
     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);
index f667e56afbbf8b11330d6328c8b2fb21b6654506..bc840ed51ffe4c571bcce1743fb7fd707cc09c2a 100644 (file)
@@ -49,7 +49,6 @@ class object "PyObject *" "&PyBaseObject_Type"
                 ((Py_ssize_t)(name)) >> 3)
 #define MCACHE_CACHEABLE_NAME(name)                             \
         PyUnicode_CheckExact(name) &&                           \
-        PyUnicode_IS_READY(name) &&                             \
         (PyUnicode_GET_LENGTH(name) <= MCACHE_MAX_ATTR_SIZE)
 
 #define NEXT_GLOBAL_VERSION_TAG _PyRuntime.types.next_version_tag
index 0686276c502aafce2eea49ee4350b8d64ae5093d..20052e2d17062d1207459418278a77991f07c87d 100644 (file)
@@ -15952,7 +15952,6 @@ _PyUnicode_ClearInterned(PyInterpreterState *interp)
     Py_ssize_t pos = 0;
     PyObject *s, *ignored_value;
     while (PyDict_Next(interned, &pos, &s, &ignored_value)) {
-        assert(PyUnicode_IS_READY(s));
         int shared = 0;
         switch (PyUnicode_CHECK_INTERNED(s)) {
         case SSTATE_INTERNED_IMMORTAL:
index 207fb6b363766c27e3e052ee61cce8d1b4e07042..45604b197f43f292872e680d087e9a23380c40d7 100644 (file)
@@ -308,9 +308,7 @@ verify_end_of_number(struct tok_state *tok, int c, const char *kind) {
     return 1;
 }
 
-/* Verify that the identifier follows PEP 3131.
-   All identifier strings are guaranteed to be "ready" unicode objects.
- */
+/* Verify that the identifier follows PEP 3131. */
 static int
 verify_identifier(struct tok_state *tok)
 {
index 83b0022e47d619615009548894c7a3998d816468..be1768d0f2cff7aab7505386c025e78945f44bc7 100644 (file)
@@ -509,8 +509,6 @@ _PyPegen_new_identifier(Parser *p, const char *n)
     if (!id) {
         goto error;
     }
-    /* PyUnicode_DecodeUTF8 should always return a ready string. */
-    assert(PyUnicode_IS_READY(id));
     /* Check whether there are non-ASCII characters in the
        identifier; if so, normalize to NFKC. */
     if (!PyUnicode_IS_ASCII(id))
index 8cdebfa1b611ea8358700fbae9a6f2d0a9bd4ede..2453929c8c789ac78d2c806bffd03aa46543a708 100644 (file)
@@ -1256,7 +1256,6 @@ _PyCodec_SurrogatePassUnicodeEncodeError(PyObject *exc)
 
     unsigned char *outp = (unsigned char *)PyBytes_AsString(res);
     for (Py_ssize_t i = start; i < end; i++) {
-        /* object is guaranteed to be "ready" */
         Py_UCS4 ch = PyUnicode_READ_CHAR(obj, i);
         if (!Py_UNICODE_IS_SURROGATE(ch)) {
             /* Not a surrogate, fail with original exception */
index 4f8662b0a4c8fba7d065a788a90ac50391478378..6e3dcb3dd66373fb06ad4cf35cacc007a21b7e25 100644 (file)
@@ -867,7 +867,6 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format,
     int result = -1;
     Py_UCS4 maxchar;
 
-    assert(PyUnicode_IS_READY(value));
     len = PyUnicode_GET_LENGTH(value);
 
     /* sign is not allowed on strings */
index d69b0ebd585a7f09baf00e06ed70342ba7e1a643..1ee040dde2262d97639e77261b6491bd3019367e 100644 (file)
@@ -249,14 +249,6 @@ tracemalloc_get_frame(_PyInterpreterFrame *pyframe, frame_t *frame)
 #endif
         return;
     }
-    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;
-    }
 
     /* intern the filename */
     _Py_hashtable_entry_t *entry;