summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-12-12 12:08:33 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-12-12 12:08:33 (GMT)
commitb0a82a6a7f0686f99e19cc04b498abcd2896b906 (patch)
treed3fe59d2ff36222b109a886eff57fc85d79a7637 /Include
parent521dfb02dd754972f04cd77d80dd34fcf5ac9399 (diff)
downloadcpython-b0a82a6a7f0686f99e19cc04b498abcd2896b906.zip
cpython-b0a82a6a7f0686f99e19cc04b498abcd2896b906.tar.gz
cpython-b0a82a6a7f0686f99e19cc04b498abcd2896b906.tar.bz2
Fix PyUnicode_Resize() for compact string: leave the string unchanged on error
Fix also PyUnicode_Resize() doc
Diffstat (limited to 'Include')
-rw-r--r--Include/unicodeobject.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 235c677..32d7df7 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -768,18 +768,15 @@ PyAPI_FUNC(int) PyUnicode_WriteChar(
PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void);
#endif
-/* Resize an Unicode object allocated by the legacy API (e.g.
- PyUnicode_FromUnicode). Unicode objects allocated by the new API (e.g.
- PyUnicode_New) cannot be resized by this function.
-
- The length is a number of characters (and not the number of Py_UNICODE characters).
+/* Resize an 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.
*unicode is modified to point to the new (resized) object and 0
returned on success.
- If the refcount on the object is 1, the function resizes the string in
- place, which is usually faster than allocating a new string (and copy
- characters).
+ Try to resize the string in place (which is usually faster than allocating
+ a new string and copy characters), or create a new string.
Error handling is implemented as follows: an exception is set, -1
is returned and *unicode left untouched. */