[Python-checkins] cpython (merge 3.6 -> default): Issue #28760: Clean up and fix comments in PyUnicode_AsUnicodeEscapeString().
serhiy.storchaka
python-checkins at python.org
Mon Nov 21 04:47:29 EST 2016
https://hg.python.org/cpython/rev/d656b93c5603
changeset: 105271:d656b93c5603
parent: 105269:94d9e97f3ee1
parent: 105270:2d0ce3f4dfbd
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Nov 21 11:47:16 2016 +0200
summary:
Issue #28760: Clean up and fix comments in PyUnicode_AsUnicodeEscapeString().
Patch by Xiang Zhang.
files:
Objects/unicodeobject.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -6118,12 +6118,7 @@
return result;
}
-/* Return a Unicode-Escape string version of the Unicode object.
-
- If quotes is true, the string is enclosed in u"" or u'' quotes as
- appropriate.
-
-*/
+/* Return a Unicode-Escape string version of the Unicode object. */
PyObject *
PyUnicode_AsUnicodeEscapeString(PyObject *unicode)
@@ -6161,10 +6156,10 @@
/* 4 byte characters can take up 10 bytes, 2 byte characters can take up 6
bytes, and 1 byte characters 4. */
expandsize = kind * 2 + 2;
- if (len > (PY_SSIZE_T_MAX - 2 - 1) / expandsize) {
+ if (len > PY_SSIZE_T_MAX / expandsize) {
return PyErr_NoMemory();
}
- repr = PyBytes_FromStringAndSize(NULL, 2 + expandsize * len + 1);
+ repr = PyBytes_FromStringAndSize(NULL, expandsize * len);
if (repr == NULL) {
return NULL;
}
@@ -6209,9 +6204,8 @@
*p++ = Py_hexdigits[ch & 0x000F];
}
}
- /* U+0000-U+00ff range: Map 16-bit characters to '\uHHHH' */
+ /* U+0100-U+ffff range: Map 16-bit characters to '\uHHHH' */
else if (ch < 0x10000) {
- /* U+0100-U+ffff */
*p++ = '\\';
*p++ = 'u';
*p++ = Py_hexdigits[(ch >> 12) & 0x000F];
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list