diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-03-23 15:10:07 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-03-23 15:10:07 (GMT) |
commit | 1c3069aed6098804f3ce4c810e07dbd02fc797c8 (patch) | |
tree | 5cf8d32196dda79d68c042de894c44d2cd0b082f /Python | |
parent | 928ad285b5eb0f25d1dabd48ff3761c205efb6f5 (diff) | |
download | cpython-1c3069aed6098804f3ce4c810e07dbd02fc797c8.zip cpython-1c3069aed6098804f3ce4c810e07dbd02fc797c8.tar.gz cpython-1c3069aed6098804f3ce4c810e07dbd02fc797c8.tar.bz2 |
Rework _Py_DumpASCII() to make Coverity happy
Diffstat (limited to 'Python')
-rw-r--r-- | Python/traceback.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Python/traceback.c b/Python/traceback.c index 3259482..62a6b1e 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -545,23 +545,23 @@ _Py_DumpASCII(int fd, PyObject *text) size = ascii->length; kind = ascii->state.kind; - if (ascii->state.compact) { + if (kind == PyUnicode_WCHAR_KIND) { + wstr = ((PyASCIIObject *)text)->wstr; + if (wstr == NULL) + return; + size = ((PyCompactUnicodeObject *)text)->wstr_length; + } + else if (ascii->state.compact) { if (ascii->state.ascii) data = ((PyASCIIObject*)text) + 1; else data = ((PyCompactUnicodeObject*)text) + 1; } - else if (kind != PyUnicode_WCHAR_KIND) { + else { data = ((PyUnicodeObject *)text)->data.any; if (data == NULL) return; } - else { - wstr = ((PyASCIIObject *)text)->wstr; - if (wstr == NULL) - return; - size = ((PyCompactUnicodeObject *)text)->wstr_length; - } if (MAX_STRING_LENGTH < size) { size = MAX_STRING_LENGTH; |