summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-04-15 00:56:21 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-04-15 00:56:21 (GMT)
commit20d325574eaa4f2a88036eac81e8d3cf9135372f (patch)
treea304da2a75e65a5b306760550c2e003d1b193e61 /Include
parent6245cb3c015a5b9febef4d6ef30d3acfc762a79d (diff)
downloadcpython-20d325574eaa4f2a88036eac81e8d3cf9135372f.zip
cpython-20d325574eaa4f2a88036eac81e8d3cf9135372f.tar.gz
cpython-20d325574eaa4f2a88036eac81e8d3cf9135372f.tar.bz2
Issue #15984: Correct PyUnicode_FromObject() and _FromEncodedObject() docs
Diffstat (limited to 'Include')
-rw-r--r--Include/unicodeobject.h24
1 files changed, 8 insertions, 16 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 4e8e3ec..ea4591d 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -844,17 +844,13 @@ PyAPI_FUNC(int) PyUnicode_Resize(
Py_ssize_t length /* New length */
);
-/* Coerce obj to a Unicode object and return a reference with
- *incremented* refcount.
+/* Decode obj to an Unicode object.
- Coercion is done in the following way:
+ bytes, bytearray and other bytes-like objects are decoded according to the
+ given encoding and error handler. The encoding and error handler can be
+ NULL to have the interface use UTF-8 and "strict".
- 1. bytes, bytearray and other bytes-like objects are decoded
- under the assumptions that they contain data using the UTF-8
- encoding. Decoding is done in "strict" mode.
-
- 2. All other objects (including Unicode objects) raise an
- exception.
+ All other objects (including Unicode objects) raise an exception.
The API returns NULL in case of an error. The caller is responsible
for decref'ing the returned objects.
@@ -867,13 +863,9 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject(
const char *errors /* error handling */
);
-/* Coerce obj to a Unicode object and return a reference with
- *incremented* refcount.
-
- Unicode objects are passed back as-is (subclasses are converted to
- true Unicode objects), all other objects are delegated to
- PyUnicode_FromEncodedObject(obj, NULL, "strict") which results in
- using UTF-8 encoding as basis for decoding the object.
+/* Copy an instance of a Unicode subtype to a new true Unicode object if
+ necessary. If obj is already a true Unicode object (not a subtype), return
+ the reference with *incremented* refcount.
The API returns NULL in case of an error. The caller is responsible
for decref'ing the returned objects.