@@ -506,14 +506,15 @@ _Py_DumpDecimal(int fd, unsigned long value)
506506
507507 This function is signal safe. */
508508
509- static void
510- dump_hexadecimal (int fd , unsigned long value , Py_ssize_t width )
509+ void
510+ _Py_DumpHexadecimal (int fd , unsigned long value , Py_ssize_t width )
511511{
512512 char buffer [sizeof (unsigned long ) * 2 + 1 ], * ptr , * end ;
513513 const Py_ssize_t size = Py_ARRAY_LENGTH (buffer ) - 1 ;
514514
515515 if (width > size )
516516 width = size ;
517+ /* it's ok if width is negative */
517518
518519 end = & buffer [size ];
519520 ptr = end ;
@@ -582,15 +583,15 @@ _Py_DumpASCII(int fd, PyObject *text)
582583 }
583584 else if (ch <= 0xff ) {
584585 PUTS (fd , "\\x" );
585- dump_hexadecimal (fd , ch , 2 );
586+ _Py_DumpHexadecimal (fd , ch , 2 );
586587 }
587588 else if (ch <= 0xffff ) {
588589 PUTS (fd , "\\u" );
589- dump_hexadecimal (fd , ch , 4 );
590+ _Py_DumpHexadecimal (fd , ch , 4 );
590591 }
591592 else {
592593 PUTS (fd , "\\U" );
593- dump_hexadecimal (fd , ch , 8 );
594+ _Py_DumpHexadecimal (fd , ch , 8 );
594595 }
595596 }
596597 if (truncated ) {
@@ -693,9 +694,9 @@ write_thread_id(int fd, PyThreadState *tstate, int is_current)
693694 PUTS (fd , "Current thread 0x" );
694695 else
695696 PUTS (fd , "Thread 0x" );
696- dump_hexadecimal (fd ,
697- (unsigned long )tstate -> thread_id ,
698- sizeof (unsigned long ) * 2 );
697+ _Py_DumpHexadecimal (fd ,
698+ (unsigned long )tstate -> thread_id ,
699+ sizeof (unsigned long ) * 2 );
699700 PUTS (fd , " (most recent call first):\n" );
700701}
701702
0 commit comments