cpython: b2f7bb63377b (original) (raw)
--- a/Include/traceback.h +++ b/Include/traceback.h @@ -94,7 +94,20 @@ PyAPI_FUNC(void) _Py_DumpASCII(int fd, P /* Format an integer as decimal into the file descriptor fd. This function is signal safe. */ -PyAPI_FUNC(void) _Py_DumpDecimal(int fd, unsigned long value); +PyAPI_FUNC(void) _Py_DumpDecimal(
+ +/* Format an integer as hexadecimal into the file descriptor fd with at least
- width digits. +
- The maximum width is sizeof(unsigned long)*2 digits. +
- This function is signal safe. */ +PyAPI_FUNC(void) _Py_DumpHexadecimal(
- int fd,
- unsigned long value,
- Py_ssize_t width);
--- a/Python/traceback.c +++ b/Python/traceback.c @@ -506,14 +506,15 @@ void This function is signal safe. */ -static void -dump_hexadecimal(int fd, unsigned long value, Py_ssize_t width) +void +_Py_DumpHexadecimal(int fd, unsigned long value, Py_ssize_t width) { char buffer[sizeof(unsigned long) * 2 + 1], *ptr, *end; const Py_ssize_t size = Py_ARRAY_LENGTH(buffer) - 1; if (width > size) width = size;
end = &buffer[size]; ptr = end; @@ -582,15 +583,15 @@ void } else if (ch <= 0xff) { PUTS(fd, "\x");
dump_hexadecimal(fd, ch, 2);[](#l2.25)
_Py_DumpHexadecimal(fd, ch, 2);[](#l2.26) }[](#l2.27) else if (ch <= 0xffff) {[](#l2.28) PUTS(fd, "\\u");[](#l2.29)
dump_hexadecimal(fd, ch, 4);[](#l2.30)
_Py_DumpHexadecimal(fd, ch, 4);[](#l2.31) }[](#l2.32) else {[](#l2.33) PUTS(fd, "\\U");[](#l2.34)
dump_hexadecimal(fd, ch, 8);[](#l2.35)
} if (truncated) { @@ -693,9 +694,9 @@ write_thread_id(int fd, PyThreadState *t PUTS(fd, "Current thread 0x"); else PUTS(fd, "Thread 0x");_Py_DumpHexadecimal(fd, ch, 8);[](#l2.36) }[](#l2.37)