mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Write _PyUnicode_Dump() to help debugging
This commit is contained in:
		
							parent
							
								
									f42dc448e0
								
							
						
					
					
						commit
						fe0c155c4f
					
				
					 1 changed files with 23 additions and 0 deletions
				
			
		| 
						 | 
					@ -515,6 +515,29 @@ void *_PyUnicode_data(void *unicode){
 | 
				
			||||||
    printf("compact data %p\n", _PyUnicode_COMPACT_DATA(unicode));
 | 
					    printf("compact data %p\n", _PyUnicode_COMPACT_DATA(unicode));
 | 
				
			||||||
    return PyUnicode_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
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PyObject *
 | 
					PyObject *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue