[Python-checkins] cpython: Rework _Py_DumpASCII() to make Coverity happy

victor.stinner python-checkins at python.org
Wed Mar 23 11:46:09 EDT 2016


https://hg.python.org/cpython/rev/3cc36e0f2325
changeset:   100692:3cc36e0f2325
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Mar 23 16:10:07 2016 +0100
summary:
  Rework _Py_DumpASCII() to make Coverity happy

files:
  Python/traceback.c |  16 ++++++++--------
  1 files changed, 8 insertions(+), 8 deletions(-)


diff --git a/Python/traceback.c b/Python/traceback.c
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -545,23 +545,23 @@
 
     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;

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list