summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-03 00:59:31 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-03 00:59:31 (GMT)
commitfe0c155c4fbcc9b5e9fa94bc1ada88287c7cc6e8 (patch)
tree02f470f96a5e3e573d132490cfe18dfb92fccd31 /Objects
parentf42dc448e0df37ed9dba7018f7fb26787f25518b (diff)
downloadcpython-fe0c155c4fbcc9b5e9fa94bc1ada88287c7cc6e8.zip
cpython-fe0c155c4fbcc9b5e9fa94bc1ada88287c7cc6e8.tar.gz
cpython-fe0c155c4fbcc9b5e9fa94bc1ada88287c7cc6e8.tar.bz2
Write _PyUnicode_Dump() to help debugging
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 8f710bd..00572a7 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -515,6 +515,29 @@ void *_PyUnicode_data(void *unicode){
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 *