@@ -886,6 +886,13 @@ dump_pointer(int fd, void *ptr)
886886 dump_hexadecimal (fd , (uintptr_t )ptr , sizeof (void * ), 1 );
887887}
888888
889+ static void
890+ dump_char (int fd , char ch )
891+ {
892+ char buf [1 ] = {ch };
893+ (void )_Py_write_noraise (fd , buf , 1 );
894+ }
895+
889896void
890897_Py_DumpASCII (int fd , PyObject * text )
891898{
@@ -945,8 +952,7 @@ _Py_DumpASCII(int fd, PyObject *text)
945952 ch = PyUnicode_READ (kind , data , i );
946953 if (' ' <= ch && ch <= 126 ) {
947954 /* printable ASCII character */
948- char c = (char )ch ;
949- (void )_Py_write_noraise (fd , & c , 1 );
955+ dump_char (fd , (char )ch );
950956 }
951957 else if (ch <= 0xff ) {
952958 PUTS (fd , "\\x" );
@@ -1283,7 +1289,7 @@ _Py_backtrace_symbols_fd(int fd, void *const *array, Py_ssize_t size)
12831289 PUTS (fd , info [i ].dli_fname );
12841290 PUTS (fd , "\", at " );
12851291 PUTS (fd , symbol_name );
1286- ( void ) _Py_write_noraise ( fd , & sign , 1 );
1292+ dump_char ( fd , sign );
12871293 PUTS (fd , "0x" );
12881294 dump_hexadecimal (fd , offset , sizeof (offset ), 1 );
12891295 PUTS (fd , " [" );
0 commit comments