bpo-42923: Py_FatalError() avoids fprintf() (GH-24242)
* Replace buffered fprintf() with unbuffered _Py_write_noraise()
in Py_FatalError().
* _Py_DumpHexadecimal() now accepts uintptr_t.
diff --git a/Python/traceback.c b/Python/traceback.c
index b82cfd3..bd5fd35 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -649,15 +649,12 @@ _Py_DumpDecimal(int fd, unsigned long value)
_Py_write_noraise(fd, ptr, end - ptr);
}
-/* Format an integer in range [0; 0xffffffff] to hexadecimal of 'width' digits,
- and write it into the file fd.
-
- This function is signal safe. */
-
+/* Format an integer as hexadecimal with width digits into fd file descriptor.
+ The function is signal safe. */
void
-_Py_DumpHexadecimal(int fd, unsigned long value, Py_ssize_t width)
+_Py_DumpHexadecimal(int fd, uintptr_t value, Py_ssize_t width)
{
- char buffer[sizeof(unsigned long) * 2 + 1], *ptr, *end;
+ char buffer[sizeof(uintptr_t) * 2 + 1], *ptr, *end;
const Py_ssize_t size = Py_ARRAY_LENGTH(buffer) - 1;
if (width > size)