Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f3ae620

Browse files
author
Victor Stinner
committed
PyUnicode_GET_SIZE() checks that PyUnicode_AsUnicode() succeed
using an assertion
1 parent dcbbd9e commit f3ae620

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Include/unicodeobject.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,13 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
385385
If the Py_UNICODE representation is not available, it will be computed
386386
on request. Use PyUnicode_GET_LENGTH() for the length in code points. */
387387

388-
#define PyUnicode_GET_SIZE(op) \
389-
(assert(PyUnicode_Check(op)), \
390-
(((PyASCIIObject *)(op))->wstr) ? \
391-
PyUnicode_WSTR_LENGTH(op) : \
392-
((void)PyUnicode_AsUnicode((PyObject *)(op)), \
393-
PyUnicode_WSTR_LENGTH(op)))
388+
#define PyUnicode_GET_SIZE(op) \
389+
(assert(PyUnicode_Check(op)), \
390+
(((PyASCIIObject *)(op))->wstr) ? \
391+
PyUnicode_WSTR_LENGTH(op) : \
392+
((void)PyUnicode_AsUnicode((PyObject *)(op)), \
393+
assert(((PyASCIIObject *)(op))->wstr), \
394+
PyUnicode_WSTR_LENGTH(op)))
394395

395396
#define PyUnicode_GET_DATA_SIZE(op) \
396397
(PyUnicode_GET_SIZE(op) * Py_UNICODE_SIZE)

0 commit comments

Comments
 (0)