[Python-checkins] cpython: Write _PyUnicode_Dump() to help debugging

victor.stinner python-checkins at python.org
Mon Oct 3 03:45:20 CEST 2011


http://hg.python.org/cpython/rev/0f227b4bd20c
changeset:   72597:0f227b4bd20c
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Mon Oct 03 02:59:31 2011 +0200
summary:
  Write _PyUnicode_Dump() to help debugging

files:
  Objects/unicodeobject.c |  23 +++++++++++++++++++++++
  1 files changed, 23 insertions(+), 0 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -515,6 +515,29 @@
     printf("compact data %p\n", _PyUnicode_COMPACT_DATA(unicode));
     return PyUnicode_DATA(unicode);
 }
+
+void
+_PyUnicode_Dump(PyObject *op)
+{
+    PyASCIIObject *ascii = (PyASCIIObject *)op;
+    printf("%s: len=%zu, wstr=%p",
+           unicode_kind_name(op),
+           ascii->length,
+           ascii->wstr);
+    if (!ascii->state.ascii) {
+        PyCompactUnicodeObject *compact = (PyCompactUnicodeObject *)op;
+        printf(" (%zu), utf8=%p (%zu)",
+               compact->wstr_length,
+               compact->utf8,
+               compact->utf8_length);
+    }
+    if (!ascii->state.compact) {
+        PyUnicodeObject *unicode = (PyUnicodeObject *)op;
+        printf(", data=%p",
+               unicode->data.any);
+    }
+    printf("\n");
+}
 #endif
 
 PyObject *

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


More information about the Python-checkins mailing list