summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-04-15 02:27:11 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-04-15 02:27:11 (GMT)
commitcda80940ed444d01beed797dcd86c207f11104bc (patch)
tree7beaa1c4db9c2e8351a9cf8ddda6a656900d4275 /Include
parent8ca020e1cc2590472ba83611727ae20d9f34bfe5 (diff)
parent20d325574eaa4f2a88036eac81e8d3cf9135372f (diff)
downloadcpython-cda80940ed444d01beed797dcd86c207f11104bc.zip
cpython-cda80940ed444d01beed797dcd86c207f11104bc.tar.gz
cpython-cda80940ed444d01beed797dcd86c207f11104bc.tar.bz2
Issue #15984: Merge PyUnicode doc from 3.5
Diffstat (limited to 'Include')
-rw-r--r--Include/bytesobject.h2
-rw-r--r--Include/unicodeobject.h28
2 files changed, 11 insertions, 19 deletions
diff --git a/Include/bytesobject.h b/Include/bytesobject.h
index 8469112..4578069 100644
--- a/Include/bytesobject.h
+++ b/Include/bytesobject.h
@@ -89,7 +89,7 @@ PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
#endif
/* Provides access to the internal data buffer and size of a string
- object or the default encoded version of an Unicode object. Passing
+ object or the default encoded version of a Unicode object. Passing
NULL as *len parameter will force the string buffer to be
0-terminated (passing a string with embedded NULL characters will
cause an exception). */
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 55d553d..791da0e 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -823,7 +823,7 @@ PyAPI_FUNC(int) PyUnicode_WriteChar(
PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void);
#endif
-/* Resize an Unicode object. The length is the number of characters, except
+/* Resize a Unicode object. The length is the number of characters, except
if the kind of the string is PyUnicode_WCHAR_KIND: in this case, the length
is the number of Py_UNICODE characters.
@@ -844,17 +844,13 @@ PyAPI_FUNC(int) PyUnicode_Resize(
Py_ssize_t length /* New length */
);
-/* Coerce obj to an 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 an 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.
@@ -998,7 +990,7 @@ _PyUnicodeWriter_WriteLatin1String(_PyUnicodeWriter *writer,
Py_ssize_t len /* length in bytes */
);
-/* Get the value of the writer as an Unicode string. Clear the
+/* Get the value of the writer as a Unicode string. Clear the
buffer of the writer. Raise an exception and return NULL
on error. */
PyAPI_FUNC(PyObject *)