mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
PyString_FromFormatV: Massage platform %p output to match what gcc does,
at least in the first two characters. %p is ill-defined, and people will forever commit bad tests otherwise ("bad" in the sense that they fall over (at least on Windows) for lack of a leading '0x'; 5 of the 7 tests in test_repr.py failed on Windows for that reason this time around).
This commit is contained in:
parent
ea46fa8494
commit
6af5bbb565
1 changed files with 8 additions and 0 deletions
|
@ -269,6 +269,14 @@ PyString_FromFormatV(const char *format, va_list vargs)
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
sprintf(s, "%p", va_arg(vargs, void*));
|
sprintf(s, "%p", va_arg(vargs, void*));
|
||||||
|
/* %p is ill-defined: ensure leading 0x. */
|
||||||
|
if (s[1] == 'X')
|
||||||
|
s[1] = 'x';
|
||||||
|
else if (s[1] != 'x') {
|
||||||
|
memmove(s+2, s, strlen(s)+1);
|
||||||
|
s[0] = '0';
|
||||||
|
s[1] = 'x';
|
||||||
|
}
|
||||||
s += strlen(s);
|
s += strlen(s);
|
||||||
break;
|
break;
|
||||||
case '%':
|
case '%':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue