@@ -844,17 +844,13 @@ PyAPI_FUNC(int) PyUnicode_Resize(
844844 Py_ssize_t length /* New length */
845845 );
846846
847- /* Coerce obj to a Unicode object and return a reference with
848- *incremented* refcount.
847+ /* Decode obj to an Unicode object.
849848
850- Coercion is done in the following way:
849+ bytes, bytearray and other bytes-like objects are decoded according to the
850+ given encoding and error handler. The encoding and error handler can be
851+ NULL to have the interface use UTF-8 and "strict".
851852
852- 1. bytes, bytearray and other bytes-like objects are decoded
853- under the assumptions that they contain data using the UTF-8
854- encoding. Decoding is done in "strict" mode.
855-
856- 2. All other objects (including Unicode objects) raise an
857- exception.
853+ All other objects (including Unicode objects) raise an exception.
858854
859855 The API returns NULL in case of an error. The caller is responsible
860856 for decref'ing the returned objects.
@@ -867,13 +863,9 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject(
867863 const char *errors /* error handling */
868864 );
869865
870- /* Coerce obj to a Unicode object and return a reference with
871- *incremented* refcount.
872-
873- Unicode objects are passed back as-is (subclasses are converted to
874- true Unicode objects), all other objects are delegated to
875- PyUnicode_FromEncodedObject(obj, NULL, "strict") which results in
876- using UTF-8 encoding as basis for decoding the object.
866+ /* Copy an instance of a Unicode subtype to a new true Unicode object if
867+ necessary. If obj is already a true Unicode object (not a subtype), return
868+ the reference with *incremented* refcount.
877869
878870 The API returns NULL in case of an error. The caller is responsible
879871 for decref'ing the returned objects.
0 commit comments