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.
This commit is contained in:
Victor Stinner 2021-01-18 18:34:56 +01:00 committed by GitHub
parent e232025025
commit 314b8787e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 50 deletions

View file

@ -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)